2 Replies Latest reply on Nov 27, 2016 5:41 AM by Dariusz Karcz

    Drawing holes centerlines creation (on side views)

    Dariusz Karcz

      Hello dear SW Api community,

       

      I have a need to create centerlines in all views apart of front view, for now i see two methods to do so:

       

      1.) Create automatic centerlines on view insert: this method however have drawbacks - it creates centerlines at places that are not intended to (I need to have centerlines on holes only), messing with options did not make any differences.

       

      2.) When on drawing page, running following run command: swCommands_InsertDetailCenterLine, this method have another drawbacks:

                a). Mouse cursor moves a 1/4 of a screen to the left

                b). I need to click "select view" in feature manager at autoinsert section

                c). I need to click view in drawing view to create centerlines

       

      Question is:

      Is there an API command to create centerlines on selected features (holes)?

      if not, is there an option to "select view" in feature manager after running swCommands_InsertDetailCenterLine command?

        • Re: Drawing holes centerlines creation (on side views)
          Peter Brinkhuis

          I don't really understand where that command comes from. I found the commands enumeration but I don't know what it's for.

           

          Fortunately I think I can still help you. What I would suggest is creating a selection of one or more views, this can be done manually or by code (SelectByID2 for example). You can then add centerlines to that view using 2015 SOLIDWORKS API Help - InsertCenterLine2 Method (IDrawingDoc)

           

          This is the cleaned up version that was first created by the macro recorder. It assumes that you have a drawing open and a view selected. In my case it was a cross-section view. It adds centerlines to the holes that are cut perfectly through the center.

           

          Sub main()

              Dim swApp As SldWorks.SldWorks

              Dim swDraw As SldWorks.DrawingDoc

              Dim boolstatus As Boolean

              Dim longstatus As Long, longwarnings As Long

              Dim myCenterLine As CenterLine

             

              Set swApp = Application.SldWorks

              Set swDraw = swApp.ActiveDoc

              'boolstatus = Part.Extension.SelectByID2("", "FACE", 0, 0, 0, False, 0, Nothing, 0)

              Set myCenterLine = swDraw.InsertCenterLine2()

              'swDraw.ClearSelection2 True

          End Sub

            • Re: Drawing holes centerlines creation (on side views)
              Dariusz Karcz

              Peter,

               

              ok, macro is working for now, but problem still remains: how to add centerlines to holes only?

              When I'm running it with drawing of weldment profiles, centerlines are added to random location of profiles.

              How to distinct holes on views without cross-section view (I assume that hidden lines are visible)?

               

              Do I need to select drawing view, then traverse all component(s) features, select ones that are circular, then select its faces and then run insertcenterline2? or maybe there is some more efficient way?