Hello,
I'm using the following code to create text below a dimension in a drawing. I would like to be able to break this up into multiple lines. If anyone can point me to how to add a carriage return to this I would appreciate it!
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swDispDim As SldWorks.DisplayDimension
Dim swDim As SldWorks.Dimension
'Dim sCurrPrefix As String
'Dim sCurrSuffix As String
'Dim sCurrCalloutAbove As String
'Dim sCurrCalloutBelow As String
'Dim sNewPrefix As String
'Dim sNewSuffix As String
'Dim sNewCalloutAbove As String
Dim sNewCalloutBelow As String
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox "Must have a SolidWorks document open." & Chr(13) & "Routine ending.", vbCritical, "Change Dimension Text"
End
End If
If swModel.GetType <> swDocDRAWING Then
MsgBox "Macro only works for Drawing files." & Chr(13) & "Routine ending.", vbCritical, "Change Dimension Text"
End
End If
Set swSelMgr = swModel.SelectionManager
If (swSelMgr.GetSelectedObjectType3(1, -1) = swSelDIMENSIONS) Then
Set swDispDim = swSelMgr.GetSelectedObject6(1, 0)
Set swDim = swDispDim.GetDimension
'Current Dimension Text
'sCurrPrefix = swDispDim.GetText(swDimensionTextPrefix)
'sCurrSuffix = swDispDim.GetText(swDimensionTextSuffix)
'sCurrCalloutAbove = swDispDim.GetText(swDimensionTextCalloutAbove)
'sCurrCalloutBelow = swDispDim.GetText(swDimensionTextCalloutBelow)
'New Dimension Text
'sNewPrefix = "My New Prefix "
'sNewSuffix = " My New Suffix"
'sNewCalloutAbove = "My New Callout Above"
sNewCalloutBelow = " THRU INLET & OUTLET FLANGES"
'*Change* Dimension Text
'swDispDim.SetText swDimensionTextPrefix, sNewPrefix
'swDispDim.SetText swDimensionTextSuffix, sNewSuffix
'swDispDim.SetText swDimensionTextCalloutAbove, sNewCalloutAbove
swDispDim.SetText swDimensionTextCalloutBelow, sNewCalloutBelow
'*Add to Current* Dimension Text
'swDispDim.SetText swDimensionTextPrefix, sCurrPrefix & sNewPrefix
'swDispDim.SetText swDimensionTextSuffix, sCurrSuffix & sNewSuffix
'swDispDim.SetText swDimensionTextCalloutAbove, sCurrCalloutAbove & sNewCalloutAbove
'swDispDim.SetText swDimensionTextCalloutBelow, sCurrCalloutBelow & sNewCalloutBelow
'OVERWRITES CALLOUT BELOW
swDispDim.SetText swDimensionTextCalloutBelow, sNewCalloutBelow
End If
swModel.GraphicsRedraw2
End Sub