Does the IV2012 API allow the creation of a Yes/No parameter. If so can someone post an exapmple. I have created "Text" parameters but I am stumped on this one.
Scott A. McCoy
West-Mark Mfg.
Solved! Go to Solution.
Solved by xiaodong_liang. Go to Solution.
Hi,
Please refer to the following code. Make sure the last argument is "BOOLEAN".
Sub test()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
'bool
Dim oUserParam1 As UserParameter
Set oUserParam1 = oDoc.ComponentDefinition.Parameters.UserParameters.AddByValue("Ready", True, "BOOLEAN")
'text
Dim oUserParam2 As UserParameter
Set oUserParam2 = oCompDef.Parameters.UserParameters.AddByValue("Name", "rocky", "TEXT")
'double
Dim oUserParam3 As UserParameter
Set oUserParam3 = oCompDef.Parameters.UserParameters.AddByValue("Length", 5, kCentimeterLengthUnits)
End Sub
Best regards,
Xiaodong Liang
Developer Consultant
Autodesk Developer Technical Services
I made some changes to avoid creating additional parameter like IPE_1, IPE_2 everytime I run my rule:
Try myParam=Parameter("IPE") Catch Dim myParam As UserParameter myParam = oDoc.ComponentDefinition.Parameters.UserParameters.AddByValue("IPE", "IPE 000", "TEXT") End Try MultiValue.SetList("IPE", "IPE 080", "IPE 100", "IPE 500", "IPE 550", "IPE 600")
maybe someone will need this later...
The code above will work if you change the line
Dim oDoc As PartDocument
to
Dim oDoc As AssemblyDocument
or you can change it to
Dim oDoc As Document
and the same program will work in both parts and assemblies.
Thanks it was not so obvious. I tried it before, had some errors, wasn't sure if its the right way. Now I've tried again - code is working in iLogis but afred I delete one line. No idea why.
Dim oDoc As Document oDoc = ThisApplication.ActiveDocument Try myParam=Parameter("TYPE") Catch 'Dim myParam As UserParameter myParam = oDoc.ComponentDefinition.Parameters.UserParameters.AddByValue("TYPE", "TYPE 0", "TEXT") End Try MultiValue.SetList("TYPE", "TYPE 1", "TYPE 2")
thanks again.
Hi,
i was wondering if there is a way to add unitless user parameters?
i managed to add length type parameters but i'm unable to create a unitless.
Does this work for you:
Dim oPartDoc As Inventor.Document Set oPartDoc = ThisApplication.ActiveDocument Dim oUserParam3 As UserParameter Set oUserParam3 = oPartDoc.ComponentDefinition.Parameters.UserParameters.AddByValue("Length", 4, kUnitlessUnits)
tested in Inventor 2015
This code is not working for me in AI 2015
" set" is no longer supported and without "set" it doesn't work 😞
"set" is working only in VBA editor
which code is not working? This one?:
Try myParam=Parameter("TYPE") Catch 'Dim myParam As UserParameter myParam = oDoc.ComponentDefinition.Parameters.UserParameters.AddByValue("TYPE", "TYPE 0", "TEXT") End Try MultiValue.SetList("TYPE", "TYPE 1", "TYPE 2")
Can't find what you're looking for? Ask the community or share your knowledge.