How to find OVERRIDE Dimensions in a drawing?
How to find OVERRIDE Dimensions in a drawing?
(OP)
Hi,
I want to find override dimensions seperately in a drawing which has lot of model dimensions, driven dimensions and override dimensions.
Any way to sort out the override dimensions to show in a different color?
Thanks,
Murugan.S
India.
I want to find override dimensions seperately in a drawing which has lot of model dimensions, driven dimensions and override dimensions.
Any way to sort out the override dimensions to show in a different color?
Thanks,
Murugan.S
India.






RE: How to find OVERRIDE Dimensions in a drawing?
Regards,
Scott Baugh, CSWP
www.scottjbaugh.com
FAQ731-376
RE: How to find OVERRIDE Dimensions in a drawing?
RE: How to find OVERRIDE Dimensions in a drawing?
Regards,
Scott Baugh, CSWP
www.scottjbaugh.com
FAQ731-376
RE: How to find OVERRIDE Dimensions in a drawing?
CODE
Dim swDoc As SldWorks.ModelDoc2
Dim swDwg As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swDispDim As SldWorks.DisplayDimension
Dim swDim As SldWorks.Dimension
Dim sCurPrefix As String
Dim sCurSuffix As String
Dim nOpenParPos As Long
Dim nCloseParPos As Long
Dim vDimVal As Variant
Dim dInchVal As Double
Dim sInchString As String
Dim sNewPrefix As String
Dim sNewSuffix As String
Dim KillFlag As Integer
Dim sMsg As String
Sub AddStarToOverridden()
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
If swDoc.GetType <> swDocDRAWING Then
MsgBox "This macro only works for drawing files."
Exit Sub
End If
sMsg = "This macro will add a text prefix and suffix of ""*""" & _
vbCrLf & "to all overridden dimensions in this drawing." & _
vbCrLf & vbCrLf & _
"To add or update stars on overridden dimensions, choose ""Yes""" & vbCrLf & _
"To remove all stars, choose ""No""" & _
vbCrLf & "To quit, choose ""Cancel"""
KillFlag = MsgBox(sMsg, vbYesNoCancel, "Add stars?")
If KillFlag = vbCancel Then
Exit Sub
End If
Set swDwg = swDoc
Set swView = swDwg.GetFirstView
While Not (swView Is Nothing)
Set swDispDim = swView.GetFirstDisplayDimension5
While Not swDispDim Is Nothing
Set swDim = swDispDim.GetDimension
sCurSuffix = swDispDim.GetText(swDimensionTextSuffix)
sCurPrefix = swDispDim.GetText(swDimensionTextPrefix)
If (swDispDim.GetOverride) And (KillFlag = vbYes) Then
If Right(sCurPrefix, 1) <> "*" Then
sNewPrefix = sCurPrefix & "*"
Else
sNewPrefix = sCurPrefix
End If
If Left(sCurSuffix, 1) <> "*" Then
sNewSuffix = "*" & sCurSuffix
Else
sNewSuffix = sCurSuffix
End If
Else
If Right(sCurPrefix, 1) = "*" Then
sNewPrefix = Left(sCurPrefix, Len(sCurPrefix) - 1)
Else
sNewPrefix = sCurPrefix
End If
If Left(sCurSuffix, 1) = "*" Then
sNewSuffix = Right(sCurSuffix, Len(sCurSuffix) - 1)
Else
sNewSuffix = sCurSuffix
End If
End If
swDispDim.SetText swDimensionTextSuffix, sNewSuffix
swDispDim.SetText swDimensionTextPrefix, sNewPrefix
Set swDispDim = swDispDim.GetNext5
Wend
Set swView = swView.GetNextView
Wend
End Sub
RE: How to find OVERRIDE Dimensions in a drawing?
Whenever I have used dimension that were not exact, such as rounding up to inches for nominal dims for a client, I would put it on a different layer.
Man, I have to learn C+, VB, or whatever that is.
SW06 SP5.0
Flores
RE: How to find OVERRIDE Dimensions in a drawing?
CODE
Dim swDoc As SldWorks.ModelDoc2
Dim swDwg As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swDispDim As SldWorks.DisplayDimension
Dim swAnnot As SldWorks.Annotation
Const OVERRIDDENDIMCOLOR As Integer = 255
Dim CurAnnotOverrides As Integer
Dim swDim As SldWorks.Dimension
Dim KillFlag As Integer
Dim OverRiddenFlag As Boolean
Dim sMsg As String
Sub ColorOverridden()
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
If swDoc.GetType <> swDocDRAWING Then
MsgBox "This macro only works for drawing files."
Exit Sub
End If
sMsg = "This macro will color" & _
vbCrLf & "all overridden dimensions in this drawing." & _
vbCrLf & vbCrLf & _
"To add color to overridden dimensions, choose ""Yes""" & vbCrLf & _
"To remove color, choose ""No""" & _
vbCrLf & "To quit, choose ""Cancel"""
KillFlag = MsgBox(sMsg, vbYesNoCancel, "Add stars?")
If KillFlag = vbCancel Then
Exit Sub
End If
Set swDwg = swDoc
Set swView = swDwg.GetFirstView
While Not (swView Is Nothing)
Set swDispDim = swView.GetFirstDisplayDimension5
While Not swDispDim Is Nothing
Set swAnnot = swDispDim.GetAnnotation
CurAnnotOverrides = swAnnot.LayerOverride
OverRiddenFlag = False
If CBool(swDispDim.GetOverride) Then
OverRiddenFlag = True
End If
''''Delete the section from here to "END OF SECTION TO DELETE" to only
''''color dimensions with the "Override" box checked
If CBool(swDispDim.ShowDimensionValue) Then
'do nothing
Else
OverRiddenFlag = True
End If
''''END OF SECTION TO DELETE
If (OverRiddenFlag And (KillFlag = vbYes)) Then
If CurAnnotOverrides Mod 2 <> 1 Then
swAnnot.LayerOverride = CurAnnotOverrides + 1
End If
swAnnot.Color = OVERRIDDENDIMCOLOR
Else
If CurAnnotOverrides Mod 2 = 1 Then
swAnnot.LayerOverride = CurAnnotOverrides - 1
End If
End If
Set swDispDim = swDispDim.GetNext5
Wend
Set swView = swView.GetNextView
Wend
End Sub
RE: How to find OVERRIDE Dimensions in a drawing?
thanks for all your replies.
actually one of my customer gave the drawing which has lot of model dimensions and override dimensions.As a QC engineer I have to find the override dimensions.
thanks for API coding.
regards
Murugan.S
CSWP
India.
RE: How to find OVERRIDE Dimensions in a drawing?
RE: How to find OVERRIDE Dimensions in a drawing?
Great ...! It is working.
Thanks.
Murugan.S
CSWP
India.