3 Replies Latest reply on Jul 18, 2017 3:53 AM by Ali Al-Abbasi

    How to convert a construction line to a normal line ?

    Ali Al-Abbasi

      Hello everybody,

       

      Can anyone give me an example code to convert a selected centerline to a normal line? I am using VBA..

       

      Thanks for your help

        • Re: How to convert a construction line to a normal line ?
          Simon Turner

          Dim mySeg As SketchSegment

          Dim mySelMgr as SelectionMgr

           

          Set mySelMgr = swDoc.SelectionManager

          Set mySeg = mySelMgr.GetSelectedObject6(1, -1)

          mySeg.ConstructionGeometry = False

           

           

          You should probably put some error checking in to make sure that at least one object is selected and that it is a sketch segment.

          • Re: How to convert a construction line to a normal line ?
            Ivana Kolin
            Option Explicit
            Sub main()
                Dim swApp As SldWorks.SldWorks
                Dim swModel As SldWorks.ModelDoc2
                Dim swSketchMgr As SldWorks.SketchManager
                Dim swSelMgr As SldWorks.SelectionMgr
                Dim swSketch As SldWorks.Sketch
                Dim swSketchsegment As SketchSegment
                Set swApp = Application.SldWorks
                 
                Set swModel = swApp.ActiveDoc
                Set swSelMgr = swModel.SelectionManager
                Set swSketchMgr = swModel.SketchManager
                Select Case swSelMgr.GetSelectedObjectType3(1, -1)
                    Case swSelSKETCHSEGS, swSelEXTSKETCHSEGS
                        Set swSketchsegment = swSelMgr.GetSelectedObject6(1, -1)
                        Set swSketch = swSketchMgr.ActiveSketch
                        If swSketch Is Nothing Then
                            swModel.EditSketch
                        End If
                        swSketchsegment.ConstructionGeometry = False
                    Case Else
                End Select
            End Sub
            
            • Re: How to convert a construction line to a normal line ?
              Ali Al-Abbasi

              Thanks your both (Simon and Ivana),

               

              I made it simple. You can see the code below:

               

              boolstatus = swmodel.Extension.SelectByID2("Line5", "SKETCHSEGMENT", -0, 0, 0, False, 0, Nothing, 0)

              skSegment.ConstructionGeometry = False

              swmodel.ClearSelection2 True

               

              But the funny thing that it convert another centerline in the sketch. You can see in the code I selected line5. But it converted another line (line6).

               

              Any idea to make it better?

               

              Thanks