I've been playing around with macros on my own for the last few years. I'm still a work in progress so any insight and understanding you can help me with is much appreciated.
I'm trying to use the following code to output user preference settings from the document settings. The first one (Tools > Options > Document Properties > Drafting Standards > Uppercase - All uppercase for notes) works directly how it is shown on the help page:2018 SOLIDWORKS API Help - Document Properties > Drafting Standard
The second one (Tools > Options > Document Properties > Annotations > Text - Font...) I think I understand that I needed to use the "Set" command because the Text Format is an object that holds many member values? Do I understand correctly? So each value needs to be called to display. But the syntax doesn't match what is shown on the help page: 2018 SOLIDWORKS API Help - Document Properties > Annotations
The third one (Tools > Options > Document Properties > Annotations > Attachments - Edge/vertex) became available in the locals view only by adding (Dim ArrowStyle As swArrowStyle_e) This also doesn't match the help page: 2018 SOLIDWORKS API Help - Document Properties > Annotations The value shows it enum name in the locals window, but when I print the value, it shows the integer value.
How do I get the Debug.Print to show the enum value?
And why do the help files show methods that don't work for the second two?
I have the Constant type library checked.
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim ModelDocExtension As ModelDocExtension
Dim Section As String
Dim boolstatus As StringSub Main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set ModelDocExtension = Part.Extensionboolstatus = ""
Section = ""'http://help.solidworks.com/2018/english/api/sldworksapiprogguide/overview/system_options_and_document_properties.htm
'http://help.solidworks.com/2018/english/api/swconst/DP_DraftingStandard.htm
Debug.Print "Tools > Options > Document Properties > Drafting Standards > "
Section = "Uppercase - All uppercase for notes"
boolstatus = ModelDocExtension.GetUserPreferenceToggle(swUserPreferenceToggle_e.swDraftingStandardUppercase, swUserPreferenceOption_e.swDetailingNoOptionSpecified)
Debug.Print "- " & Section & ": " & vbTab & boolstatus
CLR
Debug.Print ""
'http://help.solidworks.com/2018/english/api/swconst/DP_Annotations.htmDebug.Print "Tools > Options > Document Properties > Annotations > "
'http://help.solidworks.com/2018/english/api/sldworksapi/SOLIDWORKS.Interop.sldworks~SOLIDWORKS.Interop.sldworks.ITextFormat.html
Section = "Text - Font..."
Dim swTextFormat As ITextFormat
Set swTextFormat = ModelDocExtension.GetUserPreferenceTextFormat(swUserPreferenceTextFormat_e.swDetailingAnnotationTextFormat, swUserPreferenceOption_e.swDetailingNoOptionSpecified)
Debug.Print "- " & Section & ": " & vbTab
ProcessTextFormat swApp, Part, swTextFormat'http://help.solidworks.com/2018/english/api/swconst/SOLIDWORKS.Interop.swconst~SOLIDWORKS.Interop.swconst.swArrowStyle_e.html
Section = "Attachments - Edge/vertex"
Dim ArrowStyle As swArrowStyle_e
'***FOLLOWING LINE DOES NOT WORK???***
'ArrowStyle = ModelDocExtension.GetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swDetailingArrowStyleForEdgeVertexAttachment, swUserPreferenceOption_e.swDetailingNoOptionSpecified)
'***FOLLOWING LINE OUTPUTS VALUE NOT ENUM TEXT***
Debug.Print "- " & Section & ": " & vbTab & ArrowStyle
End SubSub ProcessTextFormat(swApp As SldWorks.SldWorks, Part As SldWorks.ModelDoc2, swTextFormat As SldWorks.TextFormat)
Debug.Print " BackWards = " & swTextFormat.BackWards
Debug.Print " Bold = " & swTextFormat.Bold
Debug.Print " CharHeight = " & swTextFormat.CharHeight
Debug.Print " CharHeightInPts = " & swTextFormat.CharHeightInPts
Debug.Print " CharSpacingFactor = " & swTextFormat.CharSpacingFactor
Debug.Print " Escapement = " & swTextFormat.Escapement
Debug.Print " IsHeightSpecifiedInPts = " & swTextFormat.IsHeightSpecifiedInPts
Debug.Print " Italic = " & swTextFormat.Italic
Debug.Print " LineLength = " & swTextFormat.LineLength
Debug.Print " LineSpacing = " & swTextFormat.LineSpacing
Debug.Print " ObliqueAngle = " & swTextFormat.ObliqueAngle
Debug.Print " Strikeout = " & swTextFormat.Strikeout
Debug.Print " TypeFaceName = " & swTextFormat.TypeFaceName
Debug.Print " Underline = " & swTextFormat.Underline
Debug.Print " UpsideDown = " & swTextFormat.UpsideDown
Debug.Print " Vertical = " & swTextFormat.Vertical
Debug.Print " WidthFactor = " & swTextFormat.WidthFactor
Debug.Print ""
End SubSub CLR()
boolstatus = ""
Section = ""
End Sub
9/26/2019 Edit: I just updated the format to put the code in a quote to be easier to separate from the rest of the text.