iLogic: create unitless user parameter

iLogic: create unitless user parameter

b.graaf
Advocate Advocate
2,884 Views
8 Replies
Message 1 of 9

iLogic: create unitless user parameter

b.graaf
Advocate
Advocate

I am able to create text parameters and true/false parameters with Inventor iLogic.

 

I am using some code like this:

 

_parameter.AddByValue("Parameter name", "Parameter Value", "TEXT")

or

_parameter.AddByValue("Boolean name", "True", "BOOLEAN")

Maybe it is a dumb question, but how can I add a unitless user parameter?

0 Likes
Accepted solutions (2)
2,885 Views
8 Replies
Replies (8)
Message 2 of 9

bradeneuropeArthur
Mentor
Mentor
Accepted solution
Dim a As PartDocument
Set a = ThisDocument
Dim b As Parameters
Set b = a.ComponentDefinition.Parameters
b.UserParameters.AddByExpression "Piet", "100", "ul"

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 3 of 9

b.graaf
Advocate
Advocate

Tnx, that did the trick! 

0 Likes
Message 4 of 9

timothy_berg
Advocate
Advocate

Hello, is there more to the above code, it's not working on my end.

0 Likes
Message 5 of 9

Curtis_W
Consultant
Consultant
Accepted solution

Hi @timothy_berg, the previous solution was written in VBA, here's an iLogic example.

 

Hope that helps,

Curtis

 

This version will work for models

iLogicVb.UpdateWhenDone = True

Dim oDoc As Document = ThisDoc.Document
Dim oParams As Parameters = oDoc.ComponentDefinition.Parameters
Dim oName As String = "Test999"
Try
	oParam = oParams.UserParameters.Item(oName)
Catch
	oParam = oParams.UserParameters.AddByExpression(oName, 0, "ul")
End Try

oParam.value = 999

 

This version will work for drawings

iLogicVb.UpdateWhenDone = True

Dim oDoc As Document = ThisDoc.Document
Dim oParams As Parameters = oDoc.Parameters
Dim oName As String = "Test999"
Try
	oParam = oParams.UserParameters.Item(oName)
Catch
	oParam = oParams.UserParameters.AddByExpression(oName, 0, "ul")
End Try

oParam.value = 999

 

EESignature

Message 6 of 9

timothy_berg
Advocate
Advocate

that works, thank you sir!

Message 7 of 9

timothy_berg
Advocate
Advocate

I tried changing the code to add a true false parameter

 

Dim oDoc As Document = ThisDoc.Document
Dim oParams As Parameters = oDoc.ComponentDefinition.Parameters
Dim oName As String = "COL2"
Try
	oParam = oParams.UserParameters.Item(oName)
Catch
	oParam = oParams.UserParameters.AddByValue(oName, "True", "BOOLEAN")
End Try
oParam.value = COL2

didn't work, please let me know how to fix it, Thanks. 

0 Likes
Message 8 of 9

sbrandsen
Contributor
Contributor
UserParameters.AddByValue(oName, True, kBooleanUnits)
Message 9 of 9

timothy_berg
Advocate
Advocate

Thanks!

0 Likes