1 Reply Latest reply on Sep 16, 2016 1:29 AM by Keith Rice

    Changing visible edges to dotted lines Macro (VBA)

    Benjamin Danard

      Hello everyone,

       

      I'm working on a tool for work. Creating a 1:1 drawing for bent tubes. I'm 90% done but still working on polishing up the drawing itself.

       

      I'm overlaying two drawings on top of each other. The main tube and a larger "tolerance tube". I've hidden the tangent edges of the tolerance tube so it's just an outline around the main tube.

       

      Problem:

      I would like to change the outline of the tolerance tube to be dotted lines. I can do this by right clicking on the sketch and changing the defaults manually. But when I try to record a macro it doesn't capture this change.

       

      Is there some way to change the Visible edge line type of a drawing using a Macro?

       

      Thanks

       

      Right click on a view --> Component Line Font --> Uncheck "Use document defaults" --> Change Visible edges to dotted lines

        • Re: Changing visible edges to dotted lines Macro (VBA)
          Keith Rice

          This was a pretty straightforward problem if you know how to use the API Help. In the local API Help, I searched for "component line font" and it became apparently quickly that all of these settings were controlled in IDrawingComponent. In particular, IDrawingComponent::SetLineStyle does what you need. The second argument is where you specify the style you want. I am not certain I am using the one you want. If not, look at swLineStyles_e and find the one you want.

           

          If you want to learn how to use the API Help, check out some of the video tutorials at my web site.

           

          Dim swApp As SldWorks.SldWorks
          Dim swModel As SldWorks.ModelDoc2
          Dim swSelMgr As SldWorks.SelectionMgr
          Dim swView As SldWorks.View
          Dim swDrawComp As SldWorks.DrawingComponent
          
          Sub main()
              Set swApp = Application.SldWorks
              Set swModel = swApp.ActiveDoc
              Set swSelMgr = swModel.SelectionManager
              Set swView = swSelMgr.GetSelectedObjectsDrawingView2(1, -1)
              Set swDrawComp = swView.RootDrawingComponent
              swDrawComp.UseDocumentDefaults = False
              swDrawComp.SetLineStyle swDrawingComponentLineFontVisible, swLineHIDDEN
          End Sub
          

           

          Keith

          SolidWorks API Training and Services