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: 

Parameter types

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
oransen
452 Views, 7 Replies

Parameter types

Should I use get_Units to find out if a Model or User parameter is a double or an integer or...?

 

 

Tags (2)
7 REPLIES 7
Message 2 of 8
MegaJerk
in reply to: oransen

You would use TypeName.

MessageBox.Show(TypeName(ParameterNameHere))

 
Example

Dim frank As String 
frank = "1222"

MessageBox.Show(TypeName(frank))

 



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 3 of 8
Vladimir.Ananyev
in reply to: oransen

Numeric parameter values internally  are always Double.   

(that's why you need to be careful when compare them for equality).

Units property is useful if user parameter contains text.

In this case Parameter.Units property returns "Text".

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 4 of 8
oransen
in reply to: MegaJerk

In your example you are using VB variables. I was thinking of parameters in a parametric model. I don't think your method would work in that case.
Message 5 of 8
oransen
in reply to: Vladimir.Ananyev

So even integer counts are stored as doubles?

 

 

Message 6 of 8
Vladimir.Ananyev
in reply to: oransen

Yes, integers values of numeric parameters are stored as doubles.

You may find out that the e.g. length parameter is "integer" assuming some tolerance: 
if abs(x - round(x,6)) < 0.000001 then <x is integer>

   


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 7 of 8
oransen
in reply to: Vladimir.Ananyev

Actually suppose I should know if it is integer or double since I probably create the parameter!

Message 8 of 8
Vladimir.Ananyev
in reply to: oransen

Of course we always know if our parameter should be integer or not  Smiley Happy

But we should remember that it is rather dangerous directly compare “integer” parameter with the reference integer value:   
       If oParameter.Value = 1 then <do something>
because oParameter.Value could be equal to 1.000000000001
Be careful.

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report