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: 

grabbing user parameters from a referenced document

3 REPLIES 3
Reply
Message 1 of 4
swordmaster
279 Views, 3 Replies

grabbing user parameters from a referenced document

trying to write a external ilogic rule that will run in a idw

I want it to access the User parameters of the referenced document. Then i want to take the user parameter and write it to a string variable.

 

I have something that works up to a point, this is a shortened version of the code

 

Dim oDrawingDoc = ThisApplication.ActiveDocument

Dim oUserParams As UserParameters

For Each oRefDoc In oDrawingDoc.AllReferencedDocuments

oUserParams =oRefDoc.ComponentDefinition.Parameters.UserParameters

MessageBox.Show(oUserParams.Count & "user parameters in referenced document", "Title")

 

this works the message box returns the correct number of user parameters in the referenced document.

 

However i cannot seem to grab the value of one of the user parameters and use it.

I have tried various things like

 

Dim test As Parameter

test = oUserParams.Item("myuserparameter")

 

or (this is closer to what i want)

Dim test As String

test = oUserParams.Item("myuserparameter")

 

this errors out and i do not know why!

 

I guess i will also have to worry about units since myuserparameter is in inches  and the variable i am assigning it to is a string,

 

Any thoughts, guidance or nudges in the correct direction would be much appreciated

 

thanks in advance

 

Inventor 2010 Certified Professional
3 REPLIES 3
Message 2 of 4
Mike.Wohletz
in reply to: swordmaster

Try this:

 

Dim test As String
test = oUserParams.Item("myuserparameter").value

 

Message 3 of 4
swordmaster
in reply to: swordmaster

Mike, thanks for that.

Your suggestion worked great. Only thing i had to do was take care of the units. Since the API workes in centimetres and my parameter is in inches

 

Dim test As String

test = oUserParams.Item("myuserparameter").Value/2.54

 

There might be a more "elegant" way of converting the units, but this will do me fine

Inventor 2010 Certified Professional
Message 4 of 4
adam.nagy
in reply to: swordmaster

Hi,

 

Have a look at the UnitsOfMeasure object: http://adndevblog.typepad.com/manufacturing/2012/07/unitsofmeasure-object-and-example.html

It also has a ConvertUnits() function.

 

Cheers,



Adam Nagy
Autodesk Platform Services

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

Post to forums  

Autodesk Design & Make Report