1 Reply Latest reply on Aug 5, 2017 10:50 AM by Yong Ning

    Line Font Option with API

    Yong Ning

      Select an edge type from the list: Visible Edges

       

      Thickness

      Choose a thickness from the list, or select Custom Size and enter a Custom thickness value.

       

       

      DP_LineFont.gif

       

       

       

       

      2010 SOLIDWORKS API Help - Document Properties > Line Font  http://help.solidworks.com/2010/english/api/swconst/dp_linefont.htm

       

       

      Visible Edges - Custom thickness

      IModelDocExtension::GetUserPreferenceDouble(swUserPreferenceDoubleValue_e.swLineFontVisibleEdgesThicknessCustom, swUserPreferenceOption_e.swDetailingNoOptionSpecified)

      IModelDocExtension::SetUserPreferenceDouble(swUserPreferenceDoubleValue_e.swLineFontVisibleEdgesThicknessCustom, swUserPreferenceOption_e.swDetailingNoOptionSpecified, <Value>)

        • Re: Line Font Option with API
          Yong Ning

          2012 SOLIDWORKS API Help - Get Components in Drawing View Example (VBA)  http://help.solidworks.com/2012/english/api/sldworksapi/get_components_in_drawing_view_example_vb.htm

           

          Sub del()

             Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                 Set SwApp = Application.SldWorks

                 Set SwModel = SwApp.ActiveDoc

             Dim SwSelMgr As SelectionMgr

                 Set SwSelMgr = SwModel.SelectionManager

             Dim SwView As View

             Dim SwDrawComp As DrawingComponent

                 Set SwView = SwSelMgr.GetSelectedObject5(1)

              Set swRootDrawComp = SwView.RootDrawingComponent

              Debug.Print "File = " & SwModel.GetPathName

              Debug.Print "  View = " & SwView.Name

              vDrawChildCompArr = swRootDrawComp.GetChildren

              For Each vDrawChildComp In vDrawChildCompArr

                  Set SwDrawComp = vDrawChildComp

                  ' Returns NULL if underlying model is open in a different configuration

                  Set swComp = SwDrawComp.Component

                  If Not Nothing Is swComp Then

                      ' Returns NULL if drawing is lightweight

                      Set swCompModel = swComp.GetModelDoc2

                      Debug.Print " "

                      Debug.Print "      Component                            = " & swComp.Name2

                      Debug.Print "      Configuration                        = " & swComp.ReferencedConfiguration

                     

                      ' Turn off using document default settings for component's line font style

                      SwDrawComp.UseDocumentDefaults = False

                      Debug.Print "      Default component line font in use   = " & SwDrawComp.UseDocumentDefaults

                      ' Set new line style for visible edges

                      SwDrawComp.SetLineStyle swDrawingComponentLineFontVisible, swLineCHAIN

                      Debug.Print "        Line style for visible edges                      = " & SwDrawComp.GetLineStyle(swDrawingComponentLineFontVisible)

                      ' Set new line thickness for visible edges

                      SwDrawComp.SetLineThickness swDrawingComponentLineFontVisible, swLW_CUSTOM, 0.0003

                      lineWeight = SwDrawComp.GetLineThickness(swDrawingComponentLineFontVisible, lineThickness)

                      Debug.Print "        Line weight style and thickness for visible edges = " & lineWeight & ", " & lineThickness * 1000 & " mm"

                      If Not Nothing Is swCompModel Then

                          Debug.Print "      File                                 = " & swCompModel.GetPathName

                          Debug.Print " "

                      End If

                  End If

              Next

          End Sub