Repost: Ref parameter from ipt to iam

Repost: Ref parameter from ipt to iam

SpokenEarth
Advocate Advocate
180 Views
2 Replies
Message 1 of 3

Repost: Ref parameter from ipt to iam

SpokenEarth
Advocate
Advocate

Hi forum, I have a part with a ref parameter and a code which allow me to toggle between int and ext diameter and I want to access it / make editable from iam.
Can someone help me please?
I have enclosed files and the code, ver 2024

 

Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oSketch As PlanarSketch = oPDef.Sketches.Item("STORAGE TANK BODY")
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 = "STORAGE_TANK_EXTERNAL_DIA" Then
oHeightDim = oDim
ElseIf oDim.Parameter.Name = "STORAGE_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

 

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

marcin_otręba
Advisor
Advisor
Accepted solution

Editable for selected part or all parts in that assembly ?

 

if selected part then you can try using this:

Sub main()
set_par(ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "choose part").definition.document)
End Sub

Sub set_par(oPDoc As PartDocument)
On Error Resume Next
'	Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition

Dim oSketch As PlanarSketch = oPDef.Sketches.Item("STORAGE TANK BODY")
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 = "STORAGE_TANK_EXTERNAL_DIA" Then
oHeightDim = oDim
ElseIf oDim.Parameter.Name = "STORAGE_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
End Sub

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 3 of 3

SpokenEarth
Advocate
Advocate

Hi, just a part.....well for now.
Your code works perfect! thanks for helping me out.
Have a pleasant weekend

0 Likes