4

I was not sure of the appropriate terminology for the Title. Please suggest edits if my title is bad

SITUATION

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.

PROBLEM

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.

WHAT I HAVE TRIED SO FAR

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

SUMMARY

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.

Update

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.

ObjectBrowser

From the screen shot, there is no evidence of:

.Color
.ExtensionLineExtend
.Arrowhead1Type

Am I missing something?

James Z
  • 12,209
  • 10
  • 24
  • 44
Forward Ed
  • 9,484
  • 3
  • 22
  • 52
  • 2
    Object Browser? – urdearboy Aug 17 '18 at 20:37
  • @urdearboy did not know about ObjectBrowser...liking what I am seeing so far...sort of. – Forward Ed Aug 17 '18 at 21:06
  • 2
    There is a lot to see there... and a lot to like.... sort of. – urdearboy Aug 17 '18 at 21:19
  • @urdearboy As per update, should I have been able to see .color in the objectbrowser? – Forward Ed Aug 17 '18 at 21:35
  • 1
    Idk I don’t even know what the object you’re using is. Thanks for making me look stooopid in front of my peers ;) – urdearboy Aug 17 '18 at 22:35
  • The Google search phrase you're looking for would be [autocad object model reference](https://www.google.com/search?q=autocad+object+model+reference). – Ken White Aug 17 '18 at 23:57
  • @KenWhiteI am currently reading the First entry with the big graphic tree of items, thank you for the search terms. Still having a hard time find the list items after the ".", but I have nto been reading long. – Forward Ed Aug 18 '18 at 00:00
  • If you want code completion you need to reference the appropriate libraries in Project / References – Rno Aug 18 '18 at 00:13
  • @ArnovanBoven Since I am new to the object browser, I may have been doing it wrong, but I thought I was l looking in the AutoCAD library in the picture I uploaded under update. Top left window says AutoCAD. Is there a better way to access the library? – Forward Ed Aug 18 '18 at 00:17
  • @KenWhite From the google search result, I wound up at the [AutoDesk OBJECT MODEL](https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-ActiveX/files/GUID-A809CD71-4655-44E2-B674-1FE200B9FE30-htm.html). When I clicked on the (DimStyle) the link it brought me too was not that informative to me. However I then clicked on DIMALIGNED on the far right and at the bottom of the page underproperties were a whole slew of things I was using after the "." Am I doing something wrong? – Forward Ed Aug 18 '18 at 00:22
  • That's the ActiveX object model. You're looking for the VBA version. I can't tell you how to use their documentation. I'm just pointing out that they have it, and that's where you should be looking first.. – Ken White Aug 18 '18 at 00:25
  • 1
    @KenWhite I appreciate the help. Being self taught I wound up going down a lot of wrong paths. It gets a little frustrating at times, but also tends to make you not forget when you figure something out. – Forward Ed Aug 18 '18 at 00:27

1 Answers1

2

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.

TL;DR

Therefore you have three options when creating & configuring a new Dimension Style programmatically:

  1. Temporarily create a dimension object, configure the properties accordingly, and then use the CopyFrom method to copy such properties to your new Dimension Style.

  2. 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.

  3. 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.

Community
  • 1
  • 1
Lee Mac
  • 15,615
  • 6
  • 32
  • 80
  • 1
    Thanks for that plethora of links! – Forward Ed Apr 10 '19 at 21:41
  • You're welcome @ForwardEd - hopefully my suggestions allow you to develop a working solution, if, that is, a solution is still required after all this time! – Lee Mac Apr 11 '19 at 17:34
  • I admit I had shelved this project awhile ago, but the copyfrom process sounded really familiar. something about you do not create a style from scratch but modify and existing style then make a new style from the modified style...or something along those lines....its been more than a few months since I last had my head in this, but still sounds familiar. I also do plan on getting back to it at somepoint – Forward Ed Apr 11 '19 at 17:43