Reference parameter

Reference parameter

SpokenEarth
Advocate Advocate
393 Views
7 Replies
Message 1 of 8

Reference parameter

SpokenEarth
Advocate
Advocate

Hi forum, a few days ago I make a post regarding, toggle between parameters. I thank all the members who tried to help me, so far the solutions I'm getting back are more or less the same, in the sense of alter the exiting code or variant's of the same code.

Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oSketch As PlanarSketch = oPDef.Sketches.Item("TANK SHELL")
Dim oDims As DimensionConstraints = oSketch.DimensionConstraints
Dim oHeightDim As DimensionConstraint
Dim oAngleDim As DimensionConstraint
For Each oDim As DimensionConstraint In oDims
If oDim.Parameter.Name = "TANK_EXTERNAL_DIA" Then
oHeightDim = oDim
ElseIf oDim.Parameter.Name = "TANK_INTERNAL_DIA" Then
oAngleDim = oDim
End If
Next
If oHeightDim.Driven Then
	oAngleDim.Driven = True
	oHeightDim.Driven = False
Else
	oHeightDim.Driven = True
	oAngleDim.Driven = False
End If

The code I'm currently using is working as supposed to but it doesn't solve the issues I'm dealing with.


As you can see from the recording, I can edit and write a new value on a TANK_INTERNAL_DIA and TANK_THK, but when I run the TANK SHELL TOOGLE DIA, I can't edit the TANK_EXTERNAL_DIA or the TANK_THK, the cause is the circular reference in the equation / conflict with the reference parameter TANK_THK, which I would like to keep this option.


I would like to run the TANK_INTERNAL_DIA or the TANK_EXTERNAL_DIA whenever I choose to do so, with the TANK_THK parameter intact.
I hope and I will appreciate if someone have the time to look into it.
Thank you

0 Likes
Accepted solutions (1)
394 Views
7 Replies
Replies (7)
Message 2 of 8

daltonNYAW9
Advocate
Advocate

A solution could be that you create two new 'User Parameters' that link to the two parameters you are trying to control

I updated your model with user params "TANK_INTERNAL" and "TANK_EXTERNAL" and added to following lines

If oHeightDim.Driven Then
	oAngleDim.Driven = True
	oHeightDim.Driven = False
	Parameter.Param("TANK_EXTERNAL_DIA").Expression = Parameter.Param("TANK_EXTERNAL").Expression
	Parameter.Param("TANK_INTERNAL").Expression = Parameter.Param("TANK_INTERNAL_DIA").Expression
Else
	
	
	oHeightDim.Driven = True
	oAngleDim.Driven = False
	Parameter.Param("TANK_INTERNAL_DIA").Expression = Parameter.Param("TANK_INTERNAL").Expression
	Parameter.Param("TANK_EXTERNAL").Expression = Parameter.Param("TANK_EXTERNAL_DIA").Expression
End If
0 Likes
Message 3 of 8

daltonNYAW9
Advocate
Advocate
Accepted solution

better yet you could have a Boolean parameter that controls whether or not the parameter is editable in the form.

daltonNYAW9_0-1733170759440.png

 

Try the attached:

Message 4 of 8

SpokenEarth
Advocate
Advocate

Hi Dalton, that was exactly how I want it to function, it works perfect!!
Could you perhaps advise how I can run and edit the parameters from an iam? the code below needs some modification


Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oOccs As ComponentOccurrences = oADef.Occurrences
Dim oSkeletonOcc As ComponentOccurrence = Nothing
For Each oOcc As ComponentOccurrence In oOccs
If oOcc.Name.StartsWith("Skeleton") Then
oSkeletonOcc = oOcc
Exit For 'exit this loop
End If
Next 'oOcc
If oSkeletonOcc Is Nothing Then
MsgBox("Skeleton component not found!", vbCritical, "iLogic")
Return 'exits this rule
End If
Dim oSkeletonPDef As PartComponentDefinition = oSkeletonOcc.Definition
'Dim oSkeletonPDoc As PartDocument = oSkeletonPDef.Document
Dim oSketch As PlanarSketch = oSkeletonPDef.Sketches.Item("TANK SHELL")
Dim oDims As DimensionConstraints = oSketch.DimensionConstraints
Dim oHeightDim As DimensionConstraint
Dim oAngleDim As DimensionConstraint
For Each oDim As DimensionConstraint In oDims
If oDim.Parameter.Name = "TANK_EXTERNAL_DIA" Then
oHeightDim = oDim
ElseIf oDim.Parameter.Name = "TANK_INTERNAL_DIA" Then
oAngleDim = oDim
End If
Next
If oHeightDim.Driven Then
oAngleDim.Driven = True
oHeightDim.Driven = False
Else
oHeightDim.Driven = True
oAngleDim.Driven = False
End If

oADoc.Update2(True)

0 Likes
Message 5 of 8

daltonNYAW9
Advocate
Advocate

Are you talking about my first post or the one w/ the check box. The check box is more user-friendly imo.

I think your best solution is once you get the 'skeleton occurrence' you can either...
1. Create another rule in the skeleton doc that makes the form open then use 'run rule in component' from the assembly
2. Another option is to change the ilogic 'object provider' then run the rule in another document

 

'in part
iLogicForm.Show("Form 1")

'in assembly
iLogicVb.RunRule("PartA:1", "ruleName")


'other option
Dim oSkeletonDoc As PartDocument = oSkeletonOcc.Definiton.Document
iLogicVb.CreateObjectProvider(oSkeletonDoc).iLogicForm.Show("FORM NAME", FormMode.AsDesigned)
0 Likes
Message 6 of 8

SpokenEarth
Advocate
Advocate

I meant how to make the parameters from the part editable in the iam form, could please make an example?

0 Likes
Message 7 of 8

daltonNYAW9
Advocate
Advocate

You will need to make a rule that passes the assembly parameter/value to the part level. It's not possible to have multiple files represented on a single form.

0 Likes
Message 8 of 8

SpokenEarth
Advocate
Advocate

Hi Dalton, thank you for taking the time to help me

0 Likes