AnsweredAssumed Answered

InsertCenterMark2→double Center Mark?

Question asked by Yong Ning on Jan 27, 2015
Latest reply on Jan 27, 2015 by Yong Ning

Follow code run result is double center mark.

 

0.jpg

4

 

 

 

Sub main()

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swSelMgr As SldWorks.SelectionMgr

Dim swComp As SldWorks.Component2

Dim swView As SldWorks.View

Dim vComps As Variant

Dim vEdges As Variant

 

    Set swApp = Application.SldWorks

    swApp.SetUserPreferenceToggle swUseEnglishLanguage, True

    'Stop

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

    Set swView = swSelMgr.GetSelectedObjectsDrawingView2(1, -1)

    swModel.ClearSelection2 True

    vComps = swView.GetVisibleComponents

    Dim i As Integer

    If False = IsEmpty(vComps) Then

        For i = 0 To UBound(vComps)

            vEdges = swView.GetVisibleEntities(vComps(i), swViewEntityType_Edge)

            If False = IsEmpty(vEdges) Then

                Dim swSelData As SldWorks.SelectData

                Dim j As Integer

                Set swSelData = swSelMgr.CreateSelectData

                swSelData.View = swView

                For j = 0 To UBound(vEdges)

                    Dim swEnt As SldWorks.Entity

                    Dim swEdge As SldWorks.Edge

                    Dim swCurve As SldWorks.Curve

                    Set swEdge = vEdges(j)

                    Set swCurve = swEdge.GetCurve

                    If swCurve.IsCircle Then

                        Dim isClosed As Boolean

                        swCurve.GetEndParams 0, 0, isClosed, False

                        If isClosed Then

                            Set swEnt = swEdge

                            swEnt.Select4 True, swSelData

                        End If

                    End If

                Next

            End If

        Next

    End If

    ''

    Dim SwDraw As DrawingDoc, SwCenMark As CenterMark

       Set SwDraw = swModel

       Set CenterMark = SwDraw.InsertCenterMark2(swCenterMark_CircularGroup, True)

       'Stop

End Sub

*************************

 

run code result error ,is double center mark   see arrow

 

2.jpg

 

 

 

 

Hope run result see follow picture → single center mark.

 

 

 

 

1.jpg

Attachments

Outcomes