VBA - Dimension Styles
Another question from meHaving created a dimesnion style I want to try and set all of its values. e.g linetype bylayer. However I just can't find the information in the provided help file.
thanks in advance 1. You should draw some dimension (for ex. DIMLINEAR) and set all properties you need for this single dimension.
2. Add a new DimensionStyle to the DimensionStyles collection.
3. Use method CopyFrom for copy properties from the sample dimension to the DimensionStyle.
Current dimension style is only set of system variables which controls new dimensions properties. Use a similar syntax as listed below:
ThisDrawing.SetVariable SysvarName, sysVarData
where:
SysvarName is the name of the variable you wish to set
sysVarData is the value of the variable Excellent, thanks I'll try these when I get to work on Monday What I am trying to achiecve is the succesful creation of a new dimesnion style which will have values defined in my VBA macro for:
- colour
- Dim Lines Linetype
- Dim Lines Lineweight
- Ext line 1
- Ext Line 2
- Ext Line lineweight
- Extend Beyond Dim lines
- Offset from Origin
Still having some difficulty with this. If you already have your required Dimension Style setup in a drawing; type in _.sysvdlg at the command line.This will bring up a box with all your system variables in it.
Now the fun bit to filter everything else out, apart from all the variables associated with dimensioning.
In the top box on the left hand side; and before the * type in dim.
Then hit the Save Filtered button; name your file according to something like dim_variables.svf
Using Windows Explorer locate the file you just saved.
Right click on it, and choose Open With.
Try to select Notepad, or some other equivalent editing program.
In the file that is opened you should now see all the variables that are associated with the dimension style.
It should now be a simple process to incorporate all those settings into the sample code I posted earlier in this thread.
Look for my post #2 and this simplified example. It will draw sample aligned dimension in your drawing, creates "Wannabe_DimStyle" dimension style and copy proprties from sample dimension to your dimension style:
Sub CreationDimStyle()Dim mSp As AcadModelSpaceDim sDim As AcadDimAlignedDim pt1(0 To 2) As DoubleDim pt2(0 To 2) As DoubleDim tPos(0 To 2) As DoubleDim dCol As AcadDimStylesDim nDim As AcadDimStyle' Set poits to draw dimensionpt1(0) = 0#: pt1(1) = 0#: pt1(2) = 0#pt2(0) = 0#: pt2(1) = 100#: pt2(2) = 0#tPos(0) = 50#: tPos(1) = 15#: tPos(2) = 0#'Get Model Space CollectionSet mSp = ThisDrawing.ModelSpace' Add new sample aligned dimensionSet sDim = mSp.AddDimAligned(pt1, pt2, tPos)' Set some dimension propertiessDim.color = 1sDim.Linetype = "BYBLOCK"sDim.Lineweight = acLnWt005' Get DimensionStyles collectionSet dCol = ThisDrawing.DimStyles' Erase old "Wannabe_DimStyle" dimstyleOn Error Resume NextdCol.Item("Wannabe_DimStyle").Delete' Add new "Wannabe_DimStyle" dimstyleSet nDim = dCol.Add("Wannabe_DimStyle")'Copy properties from sample dimension sDim to dimstyle nDimnDim.CopyFrom (sDim)' Delete sample dimensionsDim.DeleteEnd Sub
Look for all dimension properties in Developer Help articles. Ok, I am now getting close to my required targets for creating a dimension style; using an aligned dimension to copy the properties from.
The problem I have is that I cannot locate any method or code that will allow me to set the linetype of the extension and dimension lines.
Everything else is perfect.
Yes this properties missed in Developer Help, therefore if you will look methods and properties of DimAligned in Object Browser you find DimensionLinetype,ExtLine1Linetype and ExtLine2Linetype properties. All used linetypes must be loaded with Load method before you will use it.
页:
[1]