Public Sub UgDimStyle_CreateNew( _
Optional ByVal sDimStyName As String = "Standard_Dim")
'------------------------------------------------------------------------------
'
'
'------------------------------------------------------------------------------
Dim CurDimStyle As AcadDimStyle
Dim NewDimstyle As AcadDimStyle
Dim iAltUnits As Integer
Dim dDimScale As Double
'''''''''''''''''''''''''''''''''''''''
'Save copy of current dimstyle
Set CurDimStyle = ThisDrawing.ActiveDimStyle
'Create new dimstyle
Set NewDimstyle = ThisDrawing.DimStyles.Add(sDimStyName)
'Set newly created dimstyle current
ThisDrawing.ActiveDimStyle = NewDimstyle
'Save the target "dimvar" values
dDimScale = ThisDrawing.GetVariable("Dimscale")
iAltUnits = ThisDrawing.GetVariable("Dimalt")
'------------------------------------------------------------------------------
'Alter the target "dimvar" values
'------------------------------------------------------------------------------
ThisDrawing.SetVariable "DIMSCALE", 1# 'will control size of dim text
ThisDrawing.SetVariable "DIMASZ", 2.5 'arrowhead size
ThisDrawing.SetVariable "DIMATFIT", 2 'arrow-text arrangement
ThisDrawing.SetVariable "DIMAZIN", 3 '0 suppression before/after angular
ThisDrawing.SetVariable "DIMBLK", "" 'special arrow blk
ThisDrawing.SetVariable "DIMDLE", 0 'dim line extension past extension
ThisDrawing.SetVariable "DIMDLI", 10 'dist between baseline dims
ThisDrawing.SetVariable "DIMDSEP", "." 'decimal separator
ThisDrawing.SetVariable "DIMEXE", 1 'dim line extension past extension
ThisDrawing.SetVariable "DIMEXO", 1 'dim offset from origin
'ThisDrawing.SetVariable "DIMFIT", 5 'control fit if not enough space
ThisDrawing.SetVariable "DIMGAP", 2 'gap around text
ThisDrawing.SetVariable "DIMJUST", 0 'text placement - above centered
ThisDrawing.SetVariable "DIMLFAC", 1# 'length scaling
ThisDrawing.SetVariable "DIMTAD", 1 'text to dim placement - above
ThisDrawing.SetVariable "DIMTIH", 0 'aligned with dim
ThisDrawing.SetVariable "DIMTIX", 0 'force inside
ThisDrawing.SetVariable "DIMTMOVE", 0 'dim moves with text
ThisDrawing.SetVariable "DIMTSZ", 0 'draw arrowheads
ThisDrawing.SetVariable "DIMTXT", 3.5 'text height
ThisDrawing.SetVariable "DIMTZIN", 12 '0 suppression before/after tol
ThisDrawing.SetVariable "DIMUNIT", 2 'unit format - decimal
ThisDrawing.SetVariable "DIMZIN", 12 '0 suppression before/after
'Copy new document dimvar settings into new dimstyle
NewDimstyle.CopyFrom ThisDrawing
'Set original dimstyle current
'ThisDrawing.ActiveDimStyle = CurDimStyle
'Restore the altered "dimvar" values
''ThisDrawing.SetVariable "Dimscale", dDimScale
''ThisDrawing.SetVariable "Dimalt", iAltUnits
'Copy restored document dimvar settings into original dimstyle
''CurDimStyle.CopyFrom ThisDrawing
Set CurDimStyle = Nothing
Set NewDimstyle = Nothing
End Sub
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (1)
Author
Commented: