2 Replies Latest reply on Nov 12, 2014 5:12 PM by Nick Hayman

    Tangent Edge Macro Button

    Nick Hayman

      Evening All,

       

      I would like the code for a button which changes the tangent edges to font, visible and hidden on a selected view.

       

      So far i have the code which changes the tangent edges to the whole page. See below.

      Also have the code of a recorded macro which doesnt work. See below.

       

      Can anyone give me the code for a button that changes the tangent edges to font, visible or hidden on a selected view? As with the first code i can then tweak the settings to suit visible, hidden and font. Depending what i require.

       

      Thankyou to all who helped in the last post.

       

      Helpful Blogger Macro - Works for whole page (not just selected view).

       

      Dim swApp As SldWorks.SldWorks

      Dim swModel As SldWorks.ModelDoc2

      Dim swDrawDoc As SldWorks.DrawingDoc

      Dim swView As SldWorks.View

       

      Dim vSheets As Variant

      Dim vViews As Variant

       

      Dim lSheetCount As Long

      Dim lViewCount As Long

       

      Dim iDisplayIn As Integer

       

      Sub main()

          Set swApp = Nothing

          Set swModel = Nothing

          Set swDrawDoc = Nothing

          Set swView = Nothing

         

          Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc

         

          If swModel Is Nothing Then Exit Sub

         

          If swModel.GetType = swDocumentTypes_e.swDocDRAWING Then

         

              ' *** Add / Remove comment mark depending on what settings of tanget edges should be.

              'iDisplayIn = swDisplayTangentEdges_e.swTangentEdgesHidden

              'iDisplayIn = swDisplayTangentEdges_e.swTangentEdgesVisible

              iDisplayIn = swDisplayTangentEdges_e.swTangentEdgesVisibleAndFonted

             

              Set swDrawDoc = swModel

             

              lViewCount = swDrawDoc.GetViewCount

              vSheets = swDrawDoc.GetViews

             

              For lSheetCount = LBound(vSheets) To UBound(vSheets)

                  vViews = vSheets(lSheetCount)

             

                  For lViewCount = LBound(vViews) To UBound(vViews)

                      vViews(lViewCount).SetDisplayTangentEdges2 (iDisplayIn)

         

                  Next

              Next

             

          End If

      End Sub

       

      ---------------------------------------------------------------------------------------------------------------------------------

      Recorded Macro which doesnt work

       

      Dim swApp As Object

       

      Dim Part As Object

      Dim boolstatus As Boolean

      Dim longstatus As Long, longwarnings As Long

       

      Sub main()

       

      Set swApp = _

      Application.SldWorks

       

      Set Part = swApp.ActiveDoc

      Dim myView As Object

      Set myView = Part.SelectionManager.GetSelectedObject3(True)

      myView.SetDisplayTangentEdges2 swDisplayTangentEdges_eswTangentEdgesVisible - DEBUG ERROR

      End Sub

        • Re: Tangent Edge Macro Button
          Daniel Andersson

          If you want to be able to multi-select views I think you have to loop thru the selected objects. This will also sort out selected edges etc etc.. Something like this...

          This macro works with selected views in the active drawing sheet.


          Dim swApp As SldWorks.SldWorks
          Dim swModel As SldWorks.ModelDoc2
          Dim swSelMgr As SldWorks.SelectionMgr

          Dim swView As SldWorks.View

          Dim iDisplayIn As Integer

           

          Sub main()
              Set swApp = Nothing
              Set swModel = Nothing
              Set swView = Nothing
             
              Set swApp = Application.SldWorks
              Set swModel = swApp.ActiveDoc
             
              If swModel Is Nothing Then Exit Sub
             
              If swModel.GetType = swDocumentTypes_e.swDocDRAWING Then
             
                  ' *** Add / Remove comment mark depending on what settings of tanget edges should be.
                  'iDisplayIn = swDisplayTangentEdges_e.swTangentEdgesHidden
                  'iDisplayIn = swDisplayTangentEdges_e.swTangentEdgesVisible
                  iDisplayIn = swDisplayTangentEdges_e.swTangentEdgesVisibleAndFonted

           

                  Set swSelMgr = swModel.SelectionManager
                 

                  For i = 0 To swSelMgr.GetSelectedObjectCount2(-1)
                      If swSelMgr.GetSelectedObjectType3(i, -1) = swSelectType_e.swSelDRAWINGVIEWS Then
                              Set swView = swSelMgr.GetSelectedObject6(i, -1)
                             swView.SetDisplayTangentEdges2  (iDisplayIn)
                      End If
                  Next


                  swModel.ClearSelection2 True
                 
              End If
          End Sub