determine how a dimension is configured
Posted: Tue Nov 09, 2021 2:26 pm
I have a part with multiple derived configurations. I sometimes make the mistake of editing dims inside the derived config thinking I am in the parent. I want to make a macro that will check that all dimensions in my derived config are linked to the parent config. So far I am able to check if the dim has been configed, but I have to check to see if it is linked to parent manually.
-Thanks
-Thanks
Code: Select all
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSketchMgr As SldWorks.SketchManager
Dim swSkRelMgr As SldWorks.SketchRelationManager
Dim swSketch As SldWorks.Sketch
Dim swDispDim As SldWorks.DisplayDimension
Dim coreDim As SldWorks.Dimension
Dim swAnn As SldWorks.Annotation
Dim vSkRelArr As Variant
Dim vSkRel As Variant
Dim dimName As String
Dim result As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSketchMgr = swModel.SketchManager
Set swSketch = swSketchMgr.ActiveSketch
Set swSkRelMgr = swSketch.RelationManager
vSkRelArr = swSkRelMgr.GetRelations(0)
'setup by editing sketch inside derived config
'attempt to find dimensions in active sketch that are configuration specific and not linked to parent config
swModel.ClearSelection2 (True)
For Each vSkRel In vSkRelArr
Set swSkRel = vSkRel
t = swSkRel.GetRelationType
If (t = swConstraintType_e.swConstraintType_DISTANCE) Or (t = swConstraintType_e.swConstraintType_DIAMETER) Or (t = swConstraintType_e.swConstraintType_ANGLE) Or (t = swConstraintType_e.swConstraintType_RADIUS) Then
Set swDispDim = swSkRel.GetDisplayDimension
Set coreDim = swDispDim.GetDimension2(0)
If coreDim.IsAppliedToAllConfigurations = False Then 'highlight all dims that are configured for manual checking
Set swAnn = swDispDim.GetAnnotation
swAnn.Select (True)
'how to check to see if dim is linked to parent configuration.
End If
End If
Next
End Sub