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
Try this:
Dim test As String test = oUserParams.Item("myuserparameter").value
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
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,