Using iLogic to reference a Parameter in Subcomponent

Using iLogic to reference a Parameter in Subcomponent

Nigel.Sims
Advocate Advocate
702 Views
2 Replies
Message 1 of 3

Using iLogic to reference a Parameter in Subcomponent

Nigel.Sims
Advocate
Advocate

Hi All,

 

I currently have an assembly that Im trying to control some sub-components from the master assembly. I know how to use iLogic to send parameter values from the top level down to sub-components, but is there a way to get a parameter value from a sub-component for use further up the chain? My current workaround is to use Parameter(MakePath) and set the value in the master assembly to that of the sub-component. I'm not going to change this value but it is needed in a simple calculation.

 

Kind regards

 

Nigel

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

clutsa
Collaborator
Collaborator

This is a really long way to get there but it seems to work.

Dim doc As AssemblyDocument = ThisDoc.Document
Dim CompDef As ComponentDefinition = doc.ComponentDefinition
Dim Assembly As ComponentOccurrence = CompDef.Occurrences.ItemByName("100000425:1") 'change as needed
'MessageBox.Show("Assembly Name = " & Assembly.Name, "Title")
Dim SubDef As AssemblyComponentDefinition = Assembly.Definition
Dim SubPart As ComponentOccurrence = SubDef.Occurrences.Item(1) 'change as needed
'MessageBox.Show("SubPart Name = " & SubPart.Name, "Title")
Dim SubContextDef As PartComponentDefinition = SubPart.Definition
ParamVal = SubContextDef.Parameters.Item(1).Value 'may try finding itemByName here too?
ParamExp = SubContextDef.Parameters.Item(1).Expression
MessageBox.Show("ParamVal = " & ParamVal & vbCr & "ParamExp = " & ParamExp, "Title")

It's not the cleanest code but a good start.

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 3 of 3

clutsa
Collaborator
Collaborator

Sorry I was in a rush yesterday and missed/forgot to rename a couple of variables. The previous code would work but it's confusing because the variables look like they are getting the parameters from "ContextDefinition" when they are actually in just "Definition"

Dim doc As AssemblyDocument = ThisDoc.Document
Dim CompDef As ComponentDefinition = doc.ComponentDefinition
Dim Assembly As ComponentOccurrence = CompDef.Occurrences.ItemByName("100000425:1") 'change as needed
'MessageBox.Show("Assembly Name = " & Assembly.Name, "Title")
Dim SubAssyDef As AssemblyComponentDefinition = Assembly.Definition
Dim SubPart As ComponentOccurrence = SubAssyDef.Occurrences.ItemByName("100000424:1") 'change as needed
'MessageBox.Show("SubPart Name = " & SubPart.Name, "Title")
Dim SubPartDef As PartComponentDefinition = SubPart.Definition
ParamVal = SubPartDef.Parameters.Item("d3").Value 'change as needed
ParamExp = SubPartDef.Parameters.Item("d3").Expression 'change as needed
MessageBox.Show("ParamVal = " & ParamVal & vbCr & "ParamExp = " & ParamExp, "Title")

 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes