Westerfield
Mechanical
- Jul 8, 2005
- 7
Is there a way to set all dimensions in a part (preferably in the template) to not be marked for drawings? I would like to just have tight tolleranced dimensions show up when new drawings are made.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Sub UnMarkAllDimsForDwg()
Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim swAnnot As SldWorks.Annotation
Dim swDispDim As SldWorks.DisplayDimension
Dim swFeat As SldWorks.Feature
Dim swSubFeat As SldWorks.Feature
Dim swDim As SldWorks.Dimension
Dim swDimTol As SldWorks.DimensionTolerance
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
'Un-mark all added reference dimensions
If swDoc.GetType <> swDocPART Then
MsgBox "This macro should only be run on parts."
Exit Sub
End If
If MsgBox("Un-mark no tolerance dims and mark all tolerance dims for dwg?", vbYesNo) = vbNo Then
Exit Sub
End If
Set swAnnot = swDoc.GetFirstAnnotation2
While Not (swAnnot Is Nothing)
If swAnnot.GetType = swDisplayDimension Then
Set swDispDim = swAnnot.GetSpecificAnnotation
Set swDim = swDispDim.GetDimension
Set swDimTol = swDim.Tolerance
If swDimTol.Type = swTolNONE Then
swDispDim.MarkedForDrawing = False
Else
swDispDim.MarkedForDrawing = True
End If
End If
Set swAnnot = swAnnot.GetNext3
Wend
'Un-mark all
Set swFeat = swDoc.FirstFeature
While Not (swFeat Is Nothing)
Set swSubFeat = swFeat.GetFirstSubFeature
While Not (swSubFeat Is Nothing)
Set swDispDim = swSubFeat.GetFirstDisplayDimension
While Not (swDispDim Is Nothing)
Set swDim = swDispDim.GetDimension
Set swDimTol = swDim.Tolerance
If swDimTol.Type = swTolNONE Then
swDispDim.MarkedForDrawing = False
Else
swDispDim.MarkedForDrawing = True
End If
Set swDispDim = swSubFeat.GetNextDisplayDimension(swDispDim)
Wend
Set swSubFeat = swSubFeat.GetNextSubFeature
Wend
Set swDispDim = swFeat.GetFirstDisplayDimension
While Not (swDispDim Is Nothing)
Set swDim = swDispDim.GetDimension
Set swDimTol = swDim.Tolerance
If swDimTol.Type = swTolNONE Then
swDispDim.MarkedForDrawing = False
Else
swDispDim.MarkedForDrawing = True
End If
Set swDispDim = swFeat.GetNextDisplayDimension(swDispDim)
Wend
Set swFeat = swFeat.GetNextFeature
Wend
Set swDispDim = Nothing
Set swDim = Nothing
Set swDimTol = Nothing
Set swAnnot = Nothing
Set swFeat = Nothing
Set swDoc = Nothing
Set swApp = Nothing
End Sub