Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
johnster100
2660 Views, 4 Replies

Add parameter to drawing file through ilogic

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

LukeDavenport
in reply to: johnster100

 

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)
johnster100
in reply to: LukeDavenport

Thanks a lot Luke, that's brilliant!

Thanks,
John
masureb
in reply to: johnster100

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”
Owner2229
in reply to: masureb

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