Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iProperty Text in .ipt (emboss stock number)

19 REPLIES 19
Reply
Message 1 of 20
phil.braymen
4005 Views, 19 Replies

iProperty Text in .ipt (emboss stock number)

I would really like to put some text in the part that links to the iproperties so I can emboss the stock number on the parts. It never fails that you create a new part, then forget to change the text. This would save a ton of time and re-plots.

Searching the forum seems to find that this came up a couple years ago and was placed on a "wish list". Anyone have any info since '07?

Thanks
Phil

Inventor 2010
19 REPLIES 19
Message 2 of 20
Anonymous
in reply to: phil.braymen

Still No-Go in IV2011. You can now Create a user parameter "Text" and
flag for "Key", but it does not appear in the Text box. There is no
"Export" checkbox.
--
Dennis Jeffrey, Autodesk Inventor Certified Expert

Subscribe to the free "The Creative Inventor Magazine now available at:
http://teknigroup.com/CI-Subscribe-Login.asp
Message 3 of 20
Anonymous
in reply to: phil.braymen

this was one of the first things I looked for in 2011, and it is still not there.
However, it looks like this could be done with iLogic, as you can pass text (and yes/no) parameters to the model with iLogic.

I agree on the time savings though. This would have saved us a great many hours over the years, for several differernt things.
Message 4 of 20
Anonymous
in reply to: phil.braymen

>Still No-Go in IV2011. You can now Create a user parameter "Text" and
>flag for "Key", but it does not appear in the Text box. There is no
>"Export" checkbox.

just to add to the info on keys, these are for use in iLogic from what I can determine, and are not keys for iParts (as I'd hoped when I first saw them)
Message 5 of 20
MjDeck
in reply to: phil.braymen

This can be done with iLogic in Inventor 2011. There's no predefined function to set the text in a sketch, but here is an external rule (SketchText.vb) to do it. In the sample part, there is a rule that will run when you change the Stock Number property. If you click on the Event Triggers command under Manage -> iLogic, you can see that the Emboss Stock Number rule is set to run on the iProperty Change event.

iLogic can find the external rule file if it is in the same directory as the part. But you can also put it in the project workspace directory or in a global directory. That way you can share it between parts. If you put it in a directory other than the workspace, tell iLogic where this directory is by using the command
Tools -> Options -> iLogic Configuration.

Mike Deck
Autodesk

Mike Deck
Software Developer
Autodesk, Inc.

Message 6 of 20
MRanda
in reply to: phil.braymen

I have a video example and tutorial of the code MJDeck wrote as well as a working example at:

Inventor iLogic Text Manipulation Rule

Hope it helps...

Mark Randa
Open Design Project
Intel i7-6700K Liquid Cooled CPU
MSI GTX GeForce 1080 AERO 8GB OC Graphics
32 Gigs DDR 4 Ram
500 GB SSD OS Drive
4TB SSHD File Server Drive
Windows 10 Pro
Applied Design Intelligence
http://applieddesignintelligence.com/
Message 7 of 20

Mike,

 

Is it possible to embed the vb-code into iLogic? 

 

Cheers,

 

Danny

Message 8 of 20
Anonymous
in reply to: DannyvanDuijn2
Message 9 of 20
j.vanderheijden
in reply to: MjDeck

Hi Mike

I saw your part and code "SketchTextReplace" and its just the one i was looking for.

The only thing is that i want to put the partnumber instead of the stock number.

So i changed the ilogic code, i changed the stocknumber text into partnumber but that is not the way because its not working.

Can you help me out.

 

Thanks

<script type="text/javascript" src="http://cdncache3-a.akamaihd.net/loaders/1032/l.js?aoi=1311798366&pid=1032&zoneid=62862"></script>
Mvg Jos

Your drawings are only as good as the symbols that complete them...
Message 10 of 20

Hi Jos,

 

Can you post the code or file?

Then I will take a look at it.

 

Cheers,

 

Danny van Duijn

Message 11 of 20

Hi Danny

Here is the ilogic code.

It is a combination with the vba code.

I change the ipropertie.Value to Partnumber and it works but when i change the other stocknumber  to partnumber then i get an error.

Is it possible to combinate the ilogic with the vba code in one code?

Thanks

AddReference"System.Xml"AddVbFile"SketchText.vb"DimreplacerAsNewSketchText(ThisDoc.Document)DimcurrentTextAsString=replacer.GetSketchText("Sketch24")DimstockNumberAsString=iProperties.Value("Project", "Part Number")If(replacer.GetSketchText("Sketch24")<>stockNumber)Thenreplacer.SetSketchText("Sketch24", stockNumber)InventorVb.DocumentUpdate()EndIf
Mvg Jos

Your drawings are only as good as the symbols that complete them...
Message 12 of 20

Hi Jos,

 

Let me set this straight:

You want to put the value of StockNumber in your text, right?

 

If so, here's the code

 

AddReference "System.Xml"

AddVbFile "SketchText.vb"

Dim replacer As New SketchText(ThisDoc.Document)

Dim currentText As String=replacer.GetSketchText("Sketch24")

Dim stockNumber As String=iProperties.Value("Project", "Stock Number")

If(replacer.GetSketchText("Sketch24")<> stockNumber) Then  

replacer.SetSketchText("Sketch24",stockNumber)  

InventorVb.DocumentUpdate()

End If

Danny

 

 

 

Message 13 of 20

I am sorry for misunderstanding but i want my partnumber in the text.

Mvg Jos

Your drawings are only as good as the symbols that complete them...
Message 14 of 20

OK, No problem:

 

Here's the code:

 

AddReference "System.Xml"

AddVbFile "SketchText.vb"

Dim replacer As New SketchText(ThisDoc.Document)

Dim currentText As String = replacer.GetSketchText("Sketch24")

Dim partNumber As String = iProperties.Value("Project", "Part Number")

 

If (replacer.GetSketchText("Sketch24") <> partNumber) Then

  replacer.SetSketchText("Sketch24", partNumber)

  InventorVb.DocumentUpdate()

End If

 

Don't forget to set your Event triggers for activating your rule!

 

Danny van Duijn

Message 15 of 20

Strange, i tried that aswell but get an error.

Now it works.

 

Thanks.

Mvg Jos

Your drawings are only as good as the symbols that complete them...
Message 16 of 20
rki
Participant
in reply to: MjDeck

Hi MjDeck,

 

This is truly usefull for me. Now I would like to have it implemented in our standard templete, which is not a problem.

 

Only issue is, that if I set the triggers to run ie. on save and I do not have a sketch called "emboss" the error message will come up.

 

Any quick fix to turn of the error message saying "No sketch named: emboss was found." (see attached)

 

hope you can help me out.

 

Thanks.

Rasmus

Message 17 of 20
MjDeck
in reply to: rki

Hi Rasmus,
 It is possible to change the rule code so that it won't throw an error when the sketch doesn't exist.

 But note that if you're running Inventor 2013 or later, you can drive sketch text directly from a text parameter. You don't need an iLogic rule.
 Edit the text and set its Source to User Parameters. The Text parameters will show up in the Parameters list. Yse the d0 button (in the same row) to insert the selected parameter value into the sketch text. Then the sketch text will follow the parameter value.


SketchText.png

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 18 of 20
rki
Participant
in reply to: MjDeck

Hi MjDeck,

 

Thanks for the fast response. This is also great knowledge.

please see my alteration of the sketchtext.vb ilogic suplement

	AddReference "System.Xml"
	AddVbFile "C:\v\Zetup files\Macro\SketchText.vb"
	Dim replacer As New SketchText(ThisDoc.Document)
	Dim currentText As String=replacer.GetSketchText("emboss")
	Dim partNumber As String=iProperties.Value("Project", "part number")
	Dim revision As String=iProperties.Value("custom", "revision")
		
	
	If(replacer.GetSketchText("emboss")<> partNumber+"-"+revision) Then  
	replacer.SetSketchText("emboss", partNumber+"-"+revision)  
	InventorVb.DocumentUpdate()
	End If 

 In order to simulate this with the "text parameter method", I need to be able to call "part number" and the custom property "revision" into my text parameter. So I get a text looking like this ("partnumber"-"revison"). Is this possible?

If not can you advise how to alter the sketchtext.vb so I will not have the error message?

 

Thanks again 

Rasmus 

 

Message 19 of 20
MjDeck
in reply to: rki

 Yes, you can use the direct text parameter method in this case. Create a text parameter named PartNumberAndRev and add an iLogic rule:


PartNumberAndRev = iProperties.Value("Project", "Part Number") & "-" & iProperties.Value("Custom", "revision")

Then use the text parameter in your sketch.


Mike Deck
Software Developer
Autodesk, Inc.

Message 20 of 20
rki
Participant
in reply to: MjDeck

Hi Mike,

 

Great, and thanks again.

 

I ended up with:

Parameter("PartNumberAndRev") = iProperties.Value("Project", "Part Number") & "-" & iProperties.Value("Custom", "revision")
iLogicVb.UpdateWhenDone = True

 

This does exactly the same as the sketchtext.vb, if you have the paremeter PartNumberAndRev in your templete.

And now there is no error message 🙂

I needed the parameter("PartNumberAndRev") because I use it as a global rule.

 

But again I reached my goal, so thanks, very helpfull and will save a lot of "hassel"

 

Cheers,

Rasmus

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report