Hey everyone:
I'm happy to report that after soaking up tons and tons of information here, I finally have something to actually contribute to the masses......
I had wanted to find a way to engrave/emboss the part number on a part model and have it be parametrically tied to the part number iProperty. Since it doesn't appear that I can create a text box and insert the iProperty directly, here's what I did to work around this. (I setup my part templates to have this out of the box....)
1. Within, the IPT file, add a user text parameter called "PartNo" and set its initial value to any text value.
2. Create your sketch for your text to be engraved. Insert the User parameter you just created.
3. Create the engraving/embossing for your text.
4. Create the following iLogic rule:
' Requires a User Text Parameter called "PartNo" prior to running ' Set the appropriate event trigger to taste If Parameter("PartNo") <> iProperties.Value("Project", "Part Number") Then Parameter("PartNo") = iProperties.Value("Project", "Part Number") InventorVb.DocumentUpdate() End If
5. I set this rule to fire using the "iProperty Change" event trigger. So if the iProperty is set or changed, your text will update. Obviously, you can set this to run with whatever trigger you like.
Use it in good health!
No problem. Glad I could finally offer something rather than just sponge!
This is a great piece of code. Thanks.
I am trying to apply it to an iPart Factory part so it propgates the part number to engraved text on each of the family member parts.
It works in the partent part, but the family parts only get the part number of whatever member is active in the parent.
Any ideas what 'trigger' I can use to make it work in this instance?
Insert the User parameter you just created.
I can't insert text parameter. Can you explain? Inventor 2012
1. Start a sketch on the plan where you want the text.
2. Make a text box where in the sketch
3. In the drop down called "source", change the value from "Model Parameters" to "User Parameters"
4. In the Parameter drop down, choose the parameter you created
5. Click the "Add Parameter" button to the right.
Now the parameter is there and you can format the text as required.....
Good luck!
Hmmm. I would have thought that I was using IV2012 when I created this procedure, but I'm not sure. If the above method doesn't work or isn't available, then you're probably right. I'm certain that I was using this in IV2013 though.
Any ideas on how to propogate this to the iPart family members?. The part number is correct in the child parts, but the text does not update.
A bit of a late response... BUT this is really great!
One thing though, I'm trying this technique to do the same in the Flat Pattern of a sheet metal part. We want the engraving to be visible only in the flat pattern. First problem is that the user text parameter that's driven by the iLogic rule, is not available in the Flat Pattern, but in the Folded Model only. Making a new user text parameter in the Flat Pattern, then in iLogic copying the program line responsible for filling in the user parameter and pointing it to the newly created parameter doesn't work. Is it even possible to control text parameters in the Flat Pattern with iLogic?
Found the solution here:
My code:
' Requires a User Text Parameter called "PartNo" prior to running ' Set the appropriate event trigger to taste Dim oDoc as Document = ThisApplication.ActiveDocument 'Get handle to active document Dim pd_Part As PartDocument = oDoc 'Get handle to part Dim cd_Def as SheetMetalComponentDefinition = pd_Part.ComponentDefinition 'Get handle to componentdefinition Dim p_param as Parameter = cd_Def.FlatPattern.Parameters.UserParameters("DXFFF") 'Declare variable linked to flat pattern user parameter TempString = iProperties.Value("Custom", "DXF_FILENAME")& "_" & iProperties.Value("Project", "Revision Number") If Parameter("DXFF") <> TempString Then 'Something changed? Then follow steps below Parameter("DXFF") = iProperties.Value("Custom", "DXF_FILENAME")& "_" & iProperties.Value("Project", "Revision Number") 'Fill Folded Model user parameter with new contents p_param.Value = Parameter("DXFF") 'Fill Flat Pattern user parameter with new contents InventorVb.DocumentUpdate() End If