Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find OVERRIDE Dimensions in a drawing? 3

Status
Not open for further replies.

murugansubham

Mechanical
Sep 24, 2003
89
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.
 
Replies continue below

Recommended for you

In SW07 overdefined are red and and conflicting are yellow. Older version they are all red conflicting and overdefined. Driven Dims are grey visible dims are black by default.

Regards,


Scott Baugh, CSWP [pc2]
faq731-376
 
I believe he's talking about value overridden dimensions in a drawing. These dimensions would not update when the model changes. I believe it's very risky practice to use these. I can see why you would want value overridden dimensions to stand out in a drawing.
 
Rather than changing the color, you can run this macro, which will enclose any overridden dimensions on the active drawing with "*".
Code:
Dim swApp As SldWorks.SldWorks
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
 
Just one note on that macro, that only works if the user picked the check-box for "Override Value" on your dimension and entered a value. If the user deleted the <DIM> as the dimension text and entered a value, then the macro will not work.
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
 
Here's an interesting tidbit... you can override the layer color for a dimension in the API, but I can't find anywhere in the user interface to do that. That's why the macro above adds stars rather than changing the color. However, I found the layer color override. I also added a check to see if the <DIM> was deleted from the text display. The downside of this, however, is that hole callouts that are "Define by hole wizard" are also caught, since those don't actually use the <DIM> but the hole wizard data. I couldn't find a good way to exclude them.

Code:
Dim swApp As SldWorks.SldWorks
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
 
Hi all,
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.
 
FYI, if you have SWX Office professional then there is no need for a macro because this functionality is already available in the SWX Design Checker.
 
Hi Stoker,
Great ...! It is working.
Thanks.

Murugan.S
CSWP
India.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor