Format and export user parameter with Ilogic

Format and export user parameter with Ilogic

Anonymous
Not applicable
6,438 Views
5 Replies
Message 1 of 6

Format and export user parameter with Ilogic

Anonymous
Not applicable

I am creating some Ilogic code that creates and formats user parameters. I have the code from jcneal for creating the user parameters but now I need to format them.  I need to check the "export parameter" checkbox and format the number in it to a specified precision.  

 

Any snippets of code would be appreciated.

Thanks

0 Likes
Accepted solutions (1)
6,439 Views
5 Replies
Replies (5)
Message 2 of 6

MjDeck
Autodesk
Autodesk

Patrick,

 

 Here's a sample rule.  You can find more detail about the CustomFormatProperty interface in the API help.  This is available in Inventor 2011 under Help -> Additional Resources -> Programming Help.

Dim partDoc as PartDocument = ThisDoc.Document
Dim userParams As UserParameters = partDoc.ComponentDefinition.Parameters.UserParameters

Dim newParam As UserParameter = userParams.AddByExpression("New0", 4.75, "in")

newParam.ExposedAsProperty = True
Dim cFormat As CustomPropertyFormat = newParam.CustomPropertyFormat
cFormat.PropertyType = CustomPropertyTypeEnum.kTextPropertyType
cFormat.Precision = CustomPropertyPrecisionEnum.kThirtySecondsFractionalLengthPrecision
' cFormat.ShowTrailingZeros = False
cFormat.ShowUnitsString = True

 

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 6

MjDeck
Autodesk
Autodesk
Accepted solution

There may be a copy and paste formatting problem with the above code.  Please use the code in the attached text document instead.


Mike Deck
Software Developer
Autodesk, Inc.

Message 4 of 6

Tigerpirro
Advocate
Advocate

I want to do the exact samt thing expet to a existing parameter, "Thickness".

But I cant seem to adapt the code correctly.

 

Any suggestions anyone?

0 Likes
Message 5 of 6

MechMachineMan
Advisor
Advisor
Search through all of the different parameter types to see if they match thickness like you want to change.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 6 of 6

karthur1
Mentor
Mentor

@Tigerpirro wrote:

I want to do the exact samt thing expet to a existing parameter, "Thickness".

But I cant seem to adapt the code correctly.

 

Any suggestions anyone?


I know this if from 2015, but others might find this useful.  If you want to format an existing "Thickness" parameter only, then try this code. The code changes this to "inch" format - 2 place decimal.

 

oThickness = Parameter.Param("Thickness")
oThickness.ExposedAsProperty = True
oFormat=oWidth.CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kTwoDecimalPlacesPrecision
oFormat.Units="inch"
oFormat.ShowUnitsString=False
'set to show/not show the unit string (use True to show)
oFormat.ShowUnitsString=False
'set to show/not show the trailing zeros (use True to show)
oFormat.ShowTrailingZeros = False
'set to show/not show the leading zeros (use True to show)
oFormat.ShowLeadingZeros = False

 

Kirk

0 Likes