Jump to content

Database concepts (Dictionary, vlax-ldata-***)


Recommended Posts

Posted

Hello :D.

 

I don't know am I on the right path here, and

I have a couple of questions.

 

First, the database.

 

I create a "private" dictionary in the main dictionary;

(setq my_dict (entmakex '((0 . "DICTIONARY")((0 . AcDbDictionary))))
(setq my_dict (dictadd (namedobjdict) "My Dictionary" my_dict))
(setq my_dict (cdr (assoc 5 (entget my_dict))))

In the last line I assoc entity handle with the var

to use with vlax-ldata-*** functions.

 

So now I do next;

(vlax-ldata-put my_dict "My List" list)

 

(my lists are lists of entities obtained with (entget (car (entsel))) lots of them)

 

And now my lists are associated with that entity handle so I can

exit acad, and find my data when I start it again.

 

My lists are retieved with dictsearch and that entity handle.

 

Is this way ok? This is my first question.

(it works fine, but I want to be sure, you know better for sure)

 

My other question.

If the first question answer is yes only.

 

Is it possible to use that saved data from another

drawing?

 

Thats it, thank you for reading and helping and everithing.

My english sucks, it is hard to me to explane, and I can

imagine what is like to understand this for you :oops:

Greetings !

 

 

p.s. I have used the search option

but I couldnt find nothing, I am very sorry.

Posted

Your fist three lines isn't no need, because vlax-ldata-put creates dictionary and XRecord automatically. Try in command line:

 

Command: (vlax-ldata-put "My Dictionary2" "My List" '(1 2 3 4))
(1 2 3 4)

 

Now check the "My Dictionary2" dictionary existance:

 

Command: (entget(namedobjdict))
((-1 . <Entity name: 7c016c60>) (0 . "DICTIONARY") (330 . <Entity name: 0>) (5 
. "C") (100 . "AcDbDictionary") (280 . 0) (281 . 1) (3 . "ACAD_COLOR") (350 . 
<Entity name: 7c016f50>) (3 . "ACAD_GROUP") (350 . <Entity name: 7c016c68>) (3 
. "ACAD_IMAGE_DICT") (350 . <Entity name: 7da8e340>) (3 . "ACAD_IMAGE_VARS") 
(350 . <Entity name: 7da8e348>) (3 . "ACAD_LAYOUT") (350 . <Entity name: 
7c016f48>) (3 . "ACAD_MATERIAL") (350 . <Entity name: 7c016c80>) (3 . 
"ACAD_MLEADERSTYLE") (350 . <Entity name: 7c016f68>) (3 . "ACAD_MLINESTYLE") 
(350 . <Entity name: 7c016f30>) (3 . "ACAD_PLOTSETTINGS") (350 . <Entity name: 
7c016f40>) (3 . "ACAD_PLOTSTYLENAME") (350 . <Entity name: 7c016c70>) (3 . 
"ACAD_SCALELIST") (350 . <Entity name: 7c016dd0>) (3 . "ACAD_TABLESTYLE") (350 
. <Entity name: 7c016f58>) (3 . "ACAD_VISUALSTYLE") (350 . <Entity name: 
7c016d48>)[color="Blue"] (3 . "My Dictionary2") (350 . <Entity name: 7c6e8788>)[/color])

 

As you can see the dictionary has been automatically added.

 

My other question.

If the first question answer is yes only.

 

Is it possible to use that saved data from another

drawing?

 

Of course yes. Again in command line. For example you have open Drawing1.dwg with "My Dictionary2" dictionary. Try from another drawing to get documents collection:

 

Command: (setq dCol(vla-get-Documents(vlax-get-acad-object)))
#<VLA-OBJECT IAcadDocuments 14474d38>

 

Get object of Drawing1.dwg:

 

Command: (setq cDoc(vla-Item dCol "Drawing1.dwg"))
#<VLA-OBJECT IAcadDocument 02000de8>

 

Get dictionaries collection:

 

Command: (setq dicts(vla-get-Dictionaries cDoc))
#<VLA-OBJECT IAcadDictionaries 1289da9c>

 

Get object of "My Dictionary2" dictionary:

 

Command: (setq di2(vla-Item dicts "My Dictionary2"))
#<VLA-OBJECT IAcadDictionary 1289daec>

 

Successfully. Extract first record:

 

Command: (setq cRec(vla-Item di2 0))
#<VLA-OBJECT IAcadObject 1289db3c>

 

Check data inside:

 

Command: (entget(vlax-vla-object->ename cRec))
((-1 . <Entity name: 7c7ef3a8>) (0 . "VLO-VL") (5 . "14D") (102 . 
"{ACAD_REACTORS") (330 . <Entity name: 7c7ef3a0>) (102 . "}") (330 . <Entity 
name: 7c7ef3a0>) (100 . "vlo_VL") (90 . -64512) (91 . 9) (92 . 0) [color="Blue"](300 . "(1 2 
3 4)")[/color])

 

It of course very simplified example without any checkups.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...