Macro selection of horizontal imported dimensions

Hi all

Is it possible to select all the horizontal or vetical dimensions of a plane by macro?

Thank you in advance for your feedback.

Yannick


2020_07_03_11_36_45_window.png

The API has an IDisplayDimension interface that has a Type2 property for an Enum SwDimensionType_e.

SwDimensionType_e.swHorLinearDimension or SwDimensionType_e.swVertLinearDimension look promising:)

 

http://help.solidworks.com/2012/english/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IDisplayDimension_members.html

Hello

This will select the vertical (or otherwise horizontal) dimensions of each sheet view.

Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swDispDim As SldWorks.DisplayDimension
Dim DisplayData As SldWorks.DisplayData
Dim swAnn As SldWorks.Annotation
Dim ArrowHeadPos1 As Variant
Dim ArrowHeadPos2 As Variant
Dim Reponse As Integer
Reponse = MsgBox("Selectionner les dimensions verticales?", vbYesNo)
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel.GetType <> swDocDRAWING Then
    MsgBox "Veuillez ouvrir un dessin"
    Exit Sub
End If
Set swDraw = swModel
swModel.ClearSelection2 True
Set swView = swDraw.GetFirstView
While Not swView Is Nothing
    Set swDispDim = swView.GetFirstDisplayDimension5
    While Not swDispDim Is Nothing
        Set DisplayData = swDispDim.GetDisplayData
        If swDispDim.GetType = swDimensionType_e.swLinearDimension And DisplayData.GetArrowHeadCount = 2 Then
            ArrowHeadPos1 = DisplayData.GetArrowHeadAtIndex2(0)
            ArrowHeadPos2 = DisplayData.GetArrowHeadAtIndex2(1)
            If Reponse = vbYes And Abs(ArrowHeadPos1(0) - ArrowHeadPos2(0)) < 0.0001 Then
                Set swAnn = swDispDim.GetAnnotation
                swAnn.Select3 True, Nothing
            ElseIf Reponse <> vbYes And Abs(ArrowHeadPos1(1) - ArrowHeadPos2(1)) < 0.0001 Then
                Set swAnn = swDispDim.GetAnnotation
                swAnn.Select3 True, Nothing
            End If
        End If
        Set swDispDim = swDispDim.GetNext5
    Wend
    Set swView = swView.GetNextView
Wend
End Sub

 

1 Like

Thank you Jerome, that's what I needed. Do you know the command line to integrate breaklines

 

What do you mean by "integrate"?

Check the Break Lines Tab

I understood that. But not what do you mean by "integrate".

I expressed myself badly, it's the weekend I have an excuse ;0)

Do you mean apply the "break" option to each vertical or horizontal dimension selected?

Yes, that's it

Unfortunately, this option does not seem to be available.