(Create/copy) Multivalue parameters with c# in inventor

(Create/copy) Multivalue parameters with c# in inventor

Anonymous
Not applicable
849 Views
2 Replies
Message 1 of 3

(Create/copy) Multivalue parameters with c# in inventor

Anonymous
Not applicable

Hi,

I want to copy a Multivalue Parameter from a document into another document using the c# API.

Until now I haven't found a way to copy the Parameter exactly as it is. So my next try is to create a new Parameter in the other document with the same properties as the Parameter in the first document, this approach works until I have to deal with Multivalue Parameters, because I can't create a Multivalue Parameter in c#.

 

To create a new Multivalue Parameter I'm trying to get the equivalent of MultiValue.SetList("PageSize", "A0", "A1", "A2", "A3", "A4") in c#

 

Thanks

0 Likes
Accepted solutions (1)
850 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor

There is a function SetExpressionList but it looks like its buged. (maby some one else can confirm that?)

In the following example i create a parameter and add a list. (when the ChangeCurrentValue boolean is set to true a exception will be thrown??) When that is done the parameter acts like it has a multivalue list. In the parameter overview there is now a dropdown menu but all values that where set are not there.

But when the i get the expression list again i get all values... (check the array newPaperSizeList )

PartDocument doc = (PartDocument)inventor.ActiveDocument;
string[] paperSizeList = { "PageSize", "A0", "A1", "A2", "A3", "A4" };
UserParameter parameter = doc.ComponentDefinition.Parameters.UserParameters.AddByValue("PaperSize", "qwe", UnitsTypeEnum.kTextUnits);
parameter.ExpressionList.SetExpressionList(paperSizeList, false, -1);

string[] newPaperSizeList = parameter.ExpressionList.GetExpressionLi

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

Thanks,

yes I get the same Problem as you, I can use SetExpressionList, if I query the ExpressionList I see there are Elements there but they aren't shown in Inventor.

 

I solved the Problem by using iLogic

string iLogicAddinGuid = "{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}";
ApplicationAddIn addin = null;
Application inventorAplication = (Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");addin = inventorAplication.ApplicationAddIns.get_ItemById(iLogicAddinGuid);
// activate the addin
if (!addin.Activated)
	addin.Activate();
Autodesk.iLogic.Automation.iLogicAutomation _iLogicAutomation = (Autodesk.iLogic.Automation.iLogicAutomation)addin.Automation;
_iLogicAutomation.set_ParamMultiValues((Document)drawDoc, paramName, expressions); 

 

0 Likes