Reputation: 9894
I was not sure of the appropriate terminology for the Title. Please suggest edits if my title is bad
I am running AutoCAD through Excel's VBA. As part of my coding, I am hard coding the base dimension style in AutoCAD. I am not using ANNOTATIVE dimension style. My plan is to copy the base dimension style as needed and just change the scale factor as required.
I found this snippit of code which basically gave me the idea to follow. The problem is I want to set every dimension option. I know if I look in AutoCAD I can see a lot of different options when setting up a style manually, or looking at the properties window for a dimension. There are a lot of them and the names in those locations are for readability and do not necessarily equal the exact syntax of their VBA name. Where can I go or what should I be reading to determine what names can be used after the "." ?
Also I discovered when doing this some of the values are not typical values but very special terms. ie. acAbove, acHorzCentered? Where should I be looking to see what to potential values are? After an hour or so of searching I stumbled on this site which gave me the potential values for arrow heads but I would hoping there was a quicker more direct way than google+guessing search terms+ clicking on random results.
GOOGLE SEARCHES up the wazoo to get links
Horizontal Options (useful results but random discovery)
Creating Dimensions (not what I was looking for)
My current code:
Dim DimStyle As AcadDimStyle
Set DimStyle = DWGFILE.DimStyles.Add("mm-0001")
With DimStyle
.Color = acByLayer
.ExtensionLineExtend = 2
.Arrowhead1Type = acArrowDefault
.Arrowhead2Type = acArrowDefault
.ArrowheadSize = 3
.TextColor = acWhite
.TextHeight = 2.5
.UnitsFormat = asDimLDecimal
.PrimaryUnitsPrecision = acDimPrecicisionZero
.TextGap = 2
.LinearScaleFactor = 1
.ExtensionLineOffset = 2
.VerticalTextPosition = acAbove
.HorizontalTextPosition = acHorzCentered
End With
Set DimStyle = DGWFile.DimStyle.Add("mm-" & Format(DimScale, "0000"))
'todo list
'copy base dimstyle to new name
'change scale factor in new name
How do you find a comprehensive list for all the dimension options I can use with Dimstyle (aka AcadDymStyle) such as:
.Color
.ExtensionLineExtend
.Arrowhead1Type
How do you find a comprehensive list for what values they can equal such as
.VerticalTextPosition = acAbove
.VerticalTextPosition = acBelow
Now in my specific example it is autocad, but I think this is pretty generic as I have beat my head against the wall for similar things within Excel and wind up eventually finding some random bit of code that happens to use the term was looking for. So while an autoCAD specific answer will help me greatly with this specific case. I am also looking for the general case that will also hopefully save my head from some bruising when I work on Excel stuff as well.
So I am poking around in ObjectBrowser (F2). I can find AcadDimStyle under Classes and I can see a bunch of members in the adjacent window which I am assuming are things I can use after the ".". Thins seems like a great starting point. The part that is confusing me for my specific case that I put as an example in this question is that not all the things that are being used after the "." are showing up in this list.
From the screen shot, there is no evidence of:
.Color
.ExtensionLineExtend
.Arrowhead1Type
Am I missing something?
Upvotes: 4
Views: 882
Reputation: 16025
Dimensions Styles in AutoCAD are somewhat of a special case.
Whereas other symbol table record objects (such as a Text Style object) have ActiveX properties & methods pertinent to the AutoCAD element that they represent (for example, a Text Style object has fontfile
, height
, obliqueangle
properties), a Dimension Style object merely has the minimum number of properties required for a symbol table record: references to parent objects, unique identifiers (handle / object ID), and a name.
Instead, the properties of a Dimension Style are stored in the DXF data found within the DIMSTYLE
symbol table, and, if the Dimension Style is active, by the values held by set of Dimension Style system variables (DIMPOST
, DIMAPOST
, DIMBLK
, DIMSCALE
, DIMASZ
, DIMEXO
, etc.) - you can use the AutoCAD SETVAR
command in the following way to obtain a full list of such system variables:
Command: SETVAR
Enter variable name or [?]: ?
Enter variable(s) to list <*>: DIM*
Now, whilst you can access the DXF data held by the DIMSTYLE
symbol table record in AutoLISP using the tblsearch
function, which might yield an association list such as the following:
_$ (tblsearch "dimstyle" "standard")
(
(0 . "DIMSTYLE")
(2 . "Standard")
(70 . 0)
(3 . "")
(4 . "")
(5 . "ClosedBlank")
(6 . "")
(7 . "")
(40 . 1.0)
(41 . 1.0)
(42 . 1.0)
(43 . 0.0)
(44 . 0.2)
(45 . 0.0)
(46 . 0.0)
(47 . 0.0)
(48 . 0.0)
(140 . 1.0)
(141 . -1.0)
(142 . 0.0)
(143 . 25.4)
(144 . 1.0)
(145 . 0.0)
(146 . 1.0)
(147 . 1.0)
(71 . 0)
(72 . 0)
(73 . 1)
(74 . 1)
(75 . 0)
(76 . 0)
(77 . 0)
(78 . 0)
(170 . 0)
(171 . 2)
(172 . 0)
(173 . 0)
(174 . 0)
(175 . 0)
(176 . 256)
(177 . 256)
(178 . 0)
(270 . 2)
(271 . 2)
(272 . 2)
(273 . 2)
(274 . 2)
(340 . <Entity name: 7ffff703910>)
(275 . 0)
(280 . 0)
(281 . 0)
(282 . 0)
(283 . 1)
(284 . 0)
(285 . 0)
(286 . 0)
(287 . 3)
(288 . 0)
)
As far as I'm aware, this data is not accessible through VBA.
However, since the individual properties controlling the appearance of Dimension objects themselves can override the Dimension Style used to create them, such dimension objects have ActiveX properties corresponding to each configurable Dimension Style setting. A reference for these properties may be found here.
Therefore you have three options when creating & configuring a new Dimension Style programmatically:
Temporarily create a dimension object, configure the properties accordingly, and then use the CopyFrom
method to copy such properties to your new Dimension Style.
Set the values of the various Dimension Style system variables accordingly (using the SetVariable
method of the AutoCAD Document
object) and then use the CopyFrom
method with the AutoCAD Document
object as the SourceObject
argument in order to copy such properties to your new Dimension Style.
Configure the Dimension Style in a separate template drawing and use the CopyObjects
method through an ObjectDBX interface to import the Dimension Style into your target drawing. I demonstrate this method in my Steal from Drawing application - the code for this application is AutoLISP, but could easily be ported to VBA.
Upvotes: 2