Create, Modify, and Copy Dimension Styles

To create a new dimension style, use the Add method. This method requires as input the name of the new dimension style.

AutoCAD ActiveX Automation allows you to add new dimension styles, and to change the active dimension style. You can also change the dimension style associated with a given dimension through the StyleName property.

You can also copy an existing style or set of overrides. Use the CopyFrom method to copy a dimension style from a source object to a new dimension style. The source object can be another DimStyle object, a dimension, Tolerance, or Leader object, or even a Document object. If you copy the style settings from another dimension style, the style is duplicated exactly. If you copy the style settings from a dimension, Tolerance, or Leader object, the current settings, including any object overrides, are copied to the new style. If you copy the style of a Document object, the active dimension style, plus any drawing overrides, is copied to the new style.

Copy dimension styles and overrides

This example creates three new dimension styles and copies the current settings for the document, a given dimension style, and a given dimension to each new dimension style respectively. By following the appropriate setup before running this example, you will find that different dimension styles have been created.

  1. Create a new drawing and make it the active drawing.
  2. Create a linear dimension in the new drawing. This dimension should be the only object in the drawing.
  3. Change the color of the dimension line to yellow.
  4. Change the DIMCLRD system variable to 5 (blue).
  5. Run the following example:
Sub Ch5_CopyDimStyles()
	Dim newStyle1 As AcadDimStyle
	Dim newStyle2 As AcadDimStyle
	Dim newStyle3 As AcadDimStyle

	Set newStyle1 = ThisDrawing.DimStyles.Add _
					("Style 1 copied from a dim")
	Call newStyle1.CopyFrom(ThisDrawing.ModelSpace(0))

	Set newStyle2 = ThisDrawing.DimStyles.Add _
					("Style 2 copied from Style 1")
	Call newStyle2.CopyFrom(ThisDrawing.DimStyles.Item _
					("Style 1 copied from a dim"))

	Set newStyle2 = ThisDrawing.DimStyles.Add _
					("Style 3 copied from the running drawing values")
	Call newStyle2.CopyFrom(ThisDrawing)
End Sub

Open the DIMSTYLE dialog box. You should now have three dimension styles listed. Style 1 should have a yellow dimension line. Style 2 should be the same as Style 1. Style 3 should have a blue dimension line.