View Full Version : Help With Dictionaries

2005-02-11, 08:36 PM
I think I am going in circles.

My objective is to trap calls to the CLOSEALL and QUIT commands in order to update some variable information stored with each drawing using LISP. This data is stored in a dictionary named "kcad" using keywords like "updates" and "initls". The function vlax-ldata-put was used to create the original entries in the dictionary.

Since CLOSEALL and QUIT operate on multiple drawings I could not use LISP for this. My first thought was to use VBA to call LISP functions I already had in place that are executed with single-drawing commands like "CLOSE". BUT... using the SendCommand method to run my LISP did not work because VBA and LISP execute asynchronously (thanks, Ed, for pointing that out). SO... you folks recommended that I do all the work in VBA. Well, I am stumped again. Below is some sample code I wrote (please don't laugh too loudly, I am new at this) that I believe gets me down to the object associated with the "updates" keyword in the "kcad" dictionary. At this point I have no clue how to access the variable data in this object. I looked at what I thought would be some examples, but I only got really confused. Can anyone help me from here? Of course I need to change/append data associated with these objects and put the revised data back into the dictionary.

Anyone willing to take a shot at this? If I am trying to do the impossible or unreasonable, please tell me so before I burn a lot more time on this!


Sub getkcad()
Dim okcad As AcadDictionary
Dim odict As AcadObject
Dim oentry As AcadObject

Set okcad = ThisDrawing.Dictionaries.Item("kcad")
MsgBox "KCAD object name: " & okcad.Name
MsgBox "KCAD object count: " & okcad.Count
Set oentry = okcad.Item("updates")
MsgBox "Made It to *updates* object in the dictionary"
End Sub

2005-02-11, 09:13 PM
The function vlax-ldata-put was used to create the original entries in the dictionary.
From what I understand, you can't access LDATA with VBA.


From AutoCAD help:

(vlax-ldata-put dictkey data) : Stores AutoLISP data in a drawing dictionary

2005-02-11, 09:42 PM
Thanks for your response, Michael.

I had noticed the comment about the vlax-ldata-* functions being for "lisp" data. Being stubborn and since there are existnig drawings with data stored this way I decded that I would see if I could get at it through VBA. If I cannot access the data stored by the vlax-ldata-* functions from VBA, is there a way to ceate a dictionary in LISP whose data can be accessed from VBA, or is this just an impossibility the way ACAD is structured?

As a less desirable alternative, I might have to figure ot a way to update the existing drawings to have VBA to store the data for me and to create all new drawings using that VBA logic. That would be lots of work.

Is XDATA an option here? Or is that just LISP data under another name stored in a different location?

I've got lots of questions.

Thanks for your time. I hope to be able to contribute answers as well as questions as I gain exterience.

AUGI Rocks!


2005-02-11, 10:17 PM
Is XDATA an option here? Or is that just LISP data under another name stored in a different location?XDATA and LDATA are different storage types. Using XDATA would be more preferable than using LDATA because it is available to BOTH VLISP and VBA. However, once the data is store as LDATA, you can not access via VBA as XDATA. :mad:

:arrow: As a solution to any LDATA that is being used now is to create a routine in VLISP that reads it out and then stores it as XDATA. After you have this routine ready, you could run a script to open all of your drawings and run the routine. 8)

:grin: HTH,

2005-02-11, 10:46 PM
Thanks, Michael.

I sort of thought that would be the case. I have never worked with XDATA, so it looks like I will have an opportunity to learn something new.

Thanks again,