6 Replies Latest reply on Feb 2, 2017 7:32 AM by Fatih Özcan

    How to disable sketch picture scale tool in Vba?

    Fatih Özcan

      Only think I am able to find in Sketch picture properties is swSketchPictureTransparencyStyle
      2016 SOLIDWORKS API Help - swSketchPictureTransparencyStyle_e Enumeration

       

      What is necessary code to disable scale tool for a sketch picture? It shows lines when sketch picture is added and because of logic of macros, I don't want to disable them manually

       

      Thanks

        • Re: How to disable sketch picture scale tool in Vba?
          Raghvendra Bhargava

          Try this:

           

          Option Explicit

           

          Dim swApp As SldWorks.SldWorks

          Dim swModel As SldWorks.ModelDoc2

          Dim swFeat As SldWorks.Feature

          Dim swSketchPicture As SldWorks.SketchPicture

          Dim swSelMgr As SldWorks.SelectionMgr

          Dim boolstatus As Boolean

          Dim width As Double

          Dim height As Double

          Dim angle As Double

           

          Sub main()

           

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

             

              Set swSelMgr = swModel.SelectionManager

              swModel.SketchManager.InsertSketch True

              Set swSketchPicture = swModel.SketchManager.InsertSketchPicture("YourImage Path")

              'swModel.SketchManager.InsertSketch True

           

           

              swApp.RunCommand swCommands_Ok_Command, "" 'It will close Command

           

           

          End Sub

            • Re: How to disable sketch picture scale tool in Vba?
              Fatih Özcan

              No luck

               

              This is what I am using right now

               

              Dim skPicture As Object
              Set skPicture.swModel.SketchMamnager.InesrtSketchPicture("image path")
              skPicture.SetSize 0.012, 0.006, 1

              skPicture.SetOrigin 0.348, 0.014

              swModel.ClearSelection

               

              'and another picture to be added with same code as upper paragraph

                • Re: How to disable sketch picture scale tool in Vba?
                  Raghvendra Bhargava

                  HiFaith,

                  There is no direct API to check or Uncheck scale tool.

                  But I got the another work around to delete scale tool.

                   

                  Try This:

                   

                  Sub main()

                  Dim swapp As SldWorks.SldWorks

                  Dim skPicture As SketchPicture

                  Dim swmodel As ModelDoc2

                   

                  Set swapp = Application.SldWorks

                  Set swmodel = swapp.ActiveDoc

                  boolstatus = swmodel.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0) '>>Select Your Plane

                  swmodel.SketchManager.InsertSketch True

                  Set skPicture = swmodel.SketchManager.InsertSketchPicture("Your Image Path")

                  skPicture.SetSize 0.012, 0.006, 1

                  skPicture.SetOrigin 0.348, 0.014

                  swmodel.ViewZoomtofit2

                  swmodel.ClearSelection

                   

                  Dim skSegment As SketchSegment

                   

                  Dim swSketch As Sketch

                  Set swSketch = swmodel.SketchManager.ActiveSketch

                   

                  Dim ArrSeg As Variant

                  ArrSeg = swSketch.GetSketchSegments

                   

                  Set skSegment = ArrSeg(0)

                  skSegment.Select4 False, Nothing

                   

                  Dim myBlockDefinition As SketchBlockDefinition

                  Set myBlockDefinition = swmodel.SketchManager.MakeSketchBlockFromSelected(Nothing)

                   

                  swmodel.EditDelete

                  swmodel.ForceRebuild3 True

                  swmodel.ViewZoomtofit2

                   

                  End Sub