3 Replies Latest reply on May 6, 2016 7:13 AM by Murat Aksoy

    CreateLine2,How to use AutoDimension2

    Yong Ning

      0.jpg

       

       

       

      follow code ,

      Set SwSketchSeg = SwModel.CreateLine2(0, 0, 0, 0, 0.01, 0) → SwsketchSeg is Nothing

       

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

       

      Private Sub ll()

         Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

             Set SwApp = Application.SldWorks

             Set SwModel = SwApp.ActiveDoc

         Dim SwSelMgr As SelectionMgr, Tmp

             Tmp = SwModel.Extension.SelectByID2("Top Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

             ''

         Dim SwSketchSeg As SketchSegment

             Set SwSketchSeg = SwModel.CreateLine2(0, 0, 0, 0, 0.01, 0)

       

       

             SwSketchSeg.Select True

             Stop

             Stop

             Stop

            

            

      End Sub

        • Re: CreateLine2,How to use AutoDimension2
          Viktor Bovzdarenko

          Hi

          Try to use InsertSketch:

           

          SwModel.InsertSketch2 True

          Set SwSketchSeg = SwModel.CreateLine2(0, 0, 0, 0, 0.01, 0)

          SwModel.InsertSketch2 True

           

          Regards

          Viktor

            • Re: CreateLine2,How to use AutoDimension2
              Yong Ning

              Thank your tips

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

              Private Sub ll()

                 Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                     Set SwApp = Application.SldWorks

                     Set SwModel = SwApp.ActiveDoc

                 Dim SwSelMgr As SelectionMgr, Tmp

                     Tmp = SwModel.Extension.SelectByID2("Top Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)

                     ''

                 Dim SwSketch As Sketch, SwSketchSeg As SketchSegment, SwAnn As Annotation

                 Dim SwFeat As Feature

                     SwModel.InsertSketch2 True

                     Set SwSketchSeg = SwModel.CreateLine2(0, 0, 0, 0, 0.01, 0)

                     Set SwSketch = SwSketchSeg.GetSketch

                     Set SwFeat = SwSketch

                 

                     SwSketchSeg.Select True

                     Set SwAnn = SwModel.AddDimension2(0, 0.01, 0)

                     SwModel.InsertSketch2 True

                     Debug.Print

                     Debug.Print SwFeat.Name

                     Stop

                    

              End Sub

            • Re: CreateLine2,How to use AutoDimension2
              Murat Aksoy

              The easiest way is to record a macro then edit it. And I strongly advise you to read api help. It tells you how you can access and use functions that you need.

               

              Murat