US$0.00
0

How to Quickly Delete Dangling Dimensions in SOLIDWORKS Drawings?

When you’re drafting using SOLIDWORKS, you’ve most likely encountered those pesky red dimensions, a very typical sign of a dangling dimensions SOLIDWORKS drawing. This is most often a result of a deleted, modified, or suppressed sketch entity or feature to which a dimension was being anchored in the model. Though they do not affect the model, these dimensions can confuse your drawing, make it illegible, and create ambiguity. The tedious and repetitive exercise of manually figuring out how to quickly delete dangling dimensions in solidworks drawings by reviewing every sheet and view is necessary in case of drawings that are more complex.

Instead of individually selecting each dimension, a good and convenient choice is to use a VBA macro. This macro itself is purpose-built to help you solidworks delete dangling dimensions by making the cleanup process more efficient. It accomplishes this by iteratively searching through every annotation on every sheet and view in the active drawing document. Once an annotation, like a dimension, is determined to be “dangling,” the macro will select it for deletion. This will save your time and energy to check and select each erroneous dimension manually, a very time-wasting and labor-intensive activity. It is the perfect way to understand how to delete dimensions in SolidWorks drawing with only one click.

' Delete all dangling dimensions
' Conditions = Active document must be drawing
' Results = Dangling dimensions deleted
' www.bluebyte.biz
Dim swApp           As Object
Dim swModel         As Object
Dim swDraw          As Object
Dim swSheet         As Object
Dim swView          As Object
Dim boolstatus      As Boolean
Dim swAnn           As Object
Dim swDispDim       As Object
Dim vSheetNames     As Variant
Public Enum swDocumentTypes_e
    swDocNONE = 0       '  Used to be TYPE_NONE
    swDocPART = 1       '  Used to be TYPE_PART
    swDocASSEMBLY = 2   '  Used to be TYPE_ASSEMBLY
    swDocDRAWING = 3    '  Used to be TYPE_DRAWING
End Enum
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
     If swModel Is Nothing Then
        swApp.SendMsgToUser ("Macro failed because there is no active drawing document.")
    ElseIf swModel.GetType <> swDocumentTypes_e.swDocDRAWING Then
        swApp.SendMsgToUser ("Macro failed because active document is not a drawing.")
    Else
        Set swDraw = swModel
        swModel.ClearSelection2 (True)
        vSheetNames = swDraw.GetSheetNames
        For i = 0 To UBound(vSheetNames)
            swDraw.ActivateSheet vSheetNames(i)
            Set swSheet = swDraw.Sheet(vSheetNames(i))
            Set swView = swDraw.GetFirstView
            Do While Not swView Is Nothing
                Set swAnn = swView.GetFirstAnnotation3
                Do While Not swAnn Is Nothing
                    If swAnn.IsDangling Then
                        swAnn.Select2 True, -1
                    End If
                    Set swAnn = swAnn.GetNext3
                Loop
                Set swView = swView.GetNextView
            Loop
            boolstatus = swModel.DeleteSelection(True)
            If boolstatus Then
             swModel.ClearSelection2 (True)
            End If
        Next i
    End If
End Sub

Author

Amen Jlili

Amen Jlili is the founder and technical director of Blue Byte Systems Inc., a software company in Vancouver, Canada, specializing in automating SOLIDWORKS and PDM. With over a decade of experience, he has authored several courses and open-source frameworks related to the SOLIDWORKS API. His leadership ensures that Blue Byte Systems prioritizes customer satisfaction and delivers high-quality software and CAD design solutions.
0
    0
    Your Cart
    Your cart is emptyReturn to Shop
    ×