Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Creating User Parameters with iLogic

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
jprochaskaYBH3W
1969 Views, 4 Replies

Creating User Parameters with iLogic

I am trying to create multi-value user parameters with iLogic, my rule works but when ran it sets the initial value to an arbitrary (or it seems so to me) value that is not in my list.  In this instance it sets the value to 4.03543307.  Once I manually go in and change it to a value that is in my set list the 4.03543307 goes away but I'm wondering why it sets the value to something I haven't assigned.  

 

Any help is greatly appreciated! Thanks!

Imports  Inventor.UnitsTypeEnum


Dim oPartDoc As Document
oPartDoc = ThisDoc.Document

If oPartDoc.DocumentType = kPartDocumentObject Then

	Dim oPartCompDef As PartComponentDefinition
		oPartCompDef = oPartDoc.ComponentDefinition
		
Dim oParams As Parameters
		oParams=oPartCompDef.Parameters
				
		Dim oUserParams As UserParameters
		oUserParams=oParams.UserParameters       
		
		Dim Width As Parameter                     
				
		Try
			otester = oUserParams.Item("Width")
			Catch
oInsulationType=oUserParams.AddByValue("Width", 10.25, kInchLengthUnits) 
MultiValue.SetList("Width", 12.25, 14.25, 16.25, 18.25)
			End Try
            End If

Parameter.Param("Width").ExposedAsProperty = False
Parameter.Param("Width").IsKey = True
4 REPLIES 4
Message 2 of 5
mcgyvr
in reply to: jprochaskaYBH3W

I'll give you a hint... 😉

convert 10.25 cm to inches = ??

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 3 of 5
jprochaskaYBH3W
in reply to: mcgyvr

Ahh yes, but why if I tell it inch units would it default to centimeters? 

 

I thought I remember reading that iLogic does all its calculations in the background in metric, but I thought it would automatically convert it back to the units specified.

 

Is there an easy way to convert it without manually putting in the conversion?

Message 4 of 5
Anonymous
in reply to: jprochaskaYBH3W

You can use AddByExpressions instead and put your number in quotations

 

oUserParams.AddByExpression("Width", "10.25", kInchLengthUnits)

 

Message 5 of 5
mcgyvr
in reply to: jprochaskaYBH3W

oInsulationType=oUserParams.AddByValue("Width", 10.25*2.54, UnitsTypeEnum.kInchLengthUnits) 


-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report