Driving parameters of components with models states, at assembly level

Driving parameters of components with models states, at assembly level

vmat8888
Enthusiast Enthusiast
229 Views
2 Replies
Message 1 of 3

Driving parameters of components with models states, at assembly level

vmat8888
Enthusiast
Enthusiast

I am trying to drive "Length" parameter of "Slotted Strut.ipt" component,part of an assembly, using iLogic. Slotted Strut.ipt component, has different models states, BUT the "Length" is the same for all of them (other parameters are different).

 

At assembly level,I created the user parameter "Strut_Lenth", through which I am trying to control "Length" parameter in Slotted Strut component.

 

I tried each of the two lines of code below, but both give me errors.

I would appreciate your help. Thank you.

 

Parameter("Slotted Strut:1", "Length") = Strut_Length

 

Parameter("Slotted Strut:1","Model State1", "Length") = Strut_Length

0 Likes
230 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor

It's not pretty but I think it does what you need:

Dim doc As AssemblyDocument = ThisDoc.Document

Dim occ1 = doc.ComponentDefinition.Occurrences.ItemByName("Slotted Strut:1")
Dim occDef = occ1.Definition

Dim modelStateUtil As ModelStateUtils = New ModelStateUtils()
Dim masterModelStateDocument As PartDocument = modelStateUtil.GetFactoryDocument(occ1.Definition.Document)

Dim masterModelStateDef = masterModelStateDocument.ComponentDefinition
masterModelStateDef.ModelStates.MemberEditScope = MemberEditScopeEnum.kEditAllMembers

Dim para As Parameter = masterModelStateDef.Parameters.UserParameters.Item("Length")
para.Expression = Strut_Length

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

vmat8888
Enthusiast
Enthusiast

Hi JelteDeJong,

Thank you, but still I get an error in line below, saying Invalid parameter.

Just a short expenation again. In Slotted Strut.ipt, I have three different Model States, Model State1, 2 and 3. They have other different parameters, BUT "Height" is the same for all three model states. I need to drive Length in Slotted Strut.ipt, through user parametyer Strut_Length in the assembly level.

Thank you.

Dim para As Parameter = masterModelStateDef.Parameters.UserParameters.Item("Length ")

 

0 Likes