Dictionary functions?

Dictionary functions?

BMcAnney
Advocate Advocate
386 Views
3 Replies
Message 1 of 4

Dictionary functions?

BMcAnney
Advocate
Advocate
I'm looking for some example code to let me save some simple data to a dictionary in the drawing. While searching the group, I've seen many references to dictionary functions by Frank Oquendo posted on Acadx.com, but that site appears to be dead.

I just need to store a small number of short strings in the drawing -- no more than 50 strings. Can anyone point me in the right direction?

Thanks!
Brent McAnney
0 Likes
387 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Hi Brent,

Nothing like the help files to get sample code.

Type a line of code like:

Dim x as AcadDictionary

Select the word "AcadDictionary" and press F1, the look for sample code.

Regards


Laurie Comerford


Sub Example_Add()
' This example adds a block, dictionary, dimension style,
' group, layer, registered application, selection set,
' textstyle, view, viewport and UCS using the Add method.

GoSub ADDBLOCK
GoSub ADDDICTIONARY
GoSub ADDDIMSTYLE
GoSub ADDGROUP
GoSub ADDLAYER
GoSub ADDREGISTEREDAPP
GoSub ADDSELECTIONSET
GoSub ADDTEXTSTYLE
GoSub ADDVIEW
GoSub ADDVIEWPORT
GoSub ADDUCS
GoSub ADDMATERIAL
Exit Sub

ADDBLOCK:
' Create a new block called "New_Block"
Dim blockObj As AcadBlock

' Define the block
Dim insertionPnt(0 To 2) As Double
insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#

' Add the block to the blocks collection
Set blockObj = ThisDrawing.Blocks.Add(insertionPnt, "New_Block")
MsgBox blockObj.name & " has been added." & vbCrLf & _
"Origin: " & blockObj.origin(0) & ", " & blockObj.origin(1) _
& ", " & blockObj.origin(2), , "Add Example"
Return

ADDDICTIONARY:
' Create a new dictionary called "New_Dictionary"
Dim dictObj As AcadDictionary

' Add the dictionary to the dictionaries collection
Set dictObj = ThisDrawing.Dictionaries.Add("New_Dictionary")
MsgBox dictObj.name & " has been added.", , "Add Example"
Return




BMcAnney wrote:
> I'm looking for some example code to let me save some simple data to a
> dictionary in the drawing. While searching the group, I've seen many
> references to dictionary functions by Frank Oquendo posted on Acadx.com,
> but that site appears to be dead. I just need to store a small number of
> short strings in the drawing -- no more than 50 strings. Can anyone
> point me in the right direction? Thanks! Brent McAnney
0 Likes
Message 3 of 4

BMcAnney
Advocate
Advocate
Thanks, Laurie. That's a good starting point, and I've gotten it to work. However, I've come to realize that it would better suit my purposes to store my data in a different construct -- say a collection or a scripting dictionary. I've read that collections cannot be stored in the a dictionary. So my question is this: can a Scripting Dictionary be stored in a dictionary? It seems to me that the AddObject method would be used for this, but I've been unable to figure it out.

Brent McAnney
0 Likes
Message 4 of 4

Anonymous
Not applicable

If you want to store persistent info then collections, scripting
dictionaries, arrays, etc won't help as they are run time objects

You would store in xrecord in a dictionary or extension dictionary

You could also use xdata but that is more limited, but if you only have a
few short strings that could also serve possibly

hth

mark


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thanks,
Laurie. That's a good starting point, and I've gotten it to work. However,
I've come to realize that it would better suit my purposes to store my data in
a different construct -- say a collection or a scripting dictionary. I've read
that collections cannot be stored in the a dictionary. So my question is this:
can a Scripting Dictionary be stored in a dictionary? It seems to me that the
AddObject method would be used for this, but I've been unable to figure it
out. Brent McAnney
0 Likes