Add parameter to drawing file through ilogic

Add parameter to drawing file through ilogic

johnster100
Collaborator Collaborator
2,832 Views
4 Replies
Message 1 of 5

Add parameter to drawing file through ilogic

johnster100
Collaborator
Collaborator

Hi there,

I'm trying to add some user parameters to a Inventor .dwg file through ilogic. I'd like to be able to add user parameter some of which will be string and some will be numbers.

 

I can't seem to find any help on the web or on the forums for this.

 

Could someone help me please?

 

thanks,

John

0 Likes
Accepted solutions (1)
2,833 Views
4 Replies
Replies (4)
Message 2 of 5

LukeDavenport
Collaborator
Collaborator
Accepted solution

 

Hi John,

 

You can add a user text parameter like this.

 

If you want it to be a multi-value parameter you'll need to create a new arraylist and add the arraylist itself as the value of the new parameter (replacing "InitialValue" in the example below:

 

Regards,

Luke

 

Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oDrawParams As UserParameters = oDrawDoc.Parameters.UserParameters

Dim TestParam As UserParameter = oDrawParams.AddByValue("TestParam" , "InitialValue", UnitsTypeEnum.kTextUnits)
Message 3 of 5

johnster100
Collaborator
Collaborator
Thanks a lot Luke, that's brilliant!

Thanks,
John
0 Likes
Message 4 of 5

masureb
Autodesk
Autodesk

Great tip. But how can we delete it or rename it?

 

Cheers,

-Bertrand

“https://damassets.autodesk.net/content/dam/autodesk/logos/autodesk-logo-primary-rgb-black-small_forum.png”
0 Likes
Message 5 of 5

Owner2229
Advisor
Advisor

Like this:

 

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oParams As UserParameters = oDoc.Parameters.UserParameters

Dim TestParam As UserParameter = oParams.Item("TestParam")
TestParam.Expression = "NewText"
TestParam.Name = "NewName" TestParam.Delete()
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes