Author Topic: Help finding dictionary's names  (Read 1583 times)

0 Members and 1 Guest are viewing this topic.

danadrian.baluta@yahoo.co

  • Guest
Help finding dictionary's names
« on: March 04, 2015, 10:45:53 AM »
Hi I'm starting working with dictionaries and I'm stuck with one problem: I couldn't find a command that shows a dictionary's name. By name I mean the custom name that I'm using with dictadd.
Example:
If I write
(setq somedict (entmakex '((0 . "DICTIONARY")(100 . "AcDbDictionary"))))
(setq newdict (dictadd (namedobjdict) "MY_DICT" somedict))
(setq entdict (cdr (assoc -1 adict)))
then I have the entity name for that dictionary.
But, when I entget this entity, I don't get the "MY_DICT" anywhwere.
Can you help me find out where the dictionary name is stored?

Thank you,
Adrian

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Help finding dictionary's names
« Reply #1 on: March 04, 2015, 10:57:52 AM »
The dictionary name is stored in (namedobjdict)
Use:
Code - Auto/Visual Lisp: [Select]
  1. (dictsearch (NAMEDOBJDICT) "MY_DICT")

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

danadrian.baluta@yahoo.co

  • Guest
Re: Help finding dictionary's names
« Reply #2 on: March 04, 2015, 11:02:22 AM »
I think I wasn't clear.
(dictsearch (NAMEDOBJDICT) "MY_DICT") returns the entity name, but it assumes I know that my dictionary is called "MY_DICT".
How do in find out the dictionary name, not the entity name?

Thank you,
Adrian

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Help finding dictionary's names
« Reply #3 on: March 04, 2015, 11:41:09 AM »
In that case you can use
Code: [Select]
(entget (namedobjdict))
BTW: Please use code tags when appropriate.

danadrian.baluta@yahoo.co

  • Guest
Re: Help finding dictionary's names
« Reply #4 on: March 04, 2015, 11:54:09 AM »
Thank you!

It was obvious, but I couldn't see it. I'm used to look inside the entity for for any data about that entity.

And I'll use code tags from now on  :-).

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Help finding dictionary's names
« Reply #5 on: March 04, 2015, 11:58:16 AM »
You could use something like this to generate a list of enames and the associated dictionary name.
Code - Auto/Visual Lisp: [Select]
  1. (vl-remove 'nil
  2.            (mapcar '(lambda (x)
  3.                       (if (= (car x) 3)
  4.                         (cons (cdr (cadr (member x l))) (cdr x))
  5.                       )
  6.                     )
  7.                    (setq l (entget (namedobjdict)))
  8.            )
  9. )


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

danadrian.baluta@yahoo.co

  • Guest
Re: Help finding dictionary's names
« Reply #6 on: March 04, 2015, 12:08:30 PM »
And thank you ronjonp!

This example also enlightened me on the use of mapcar and lambda :-).
I've seen them before in some examples and didn't quite understand how were they working together.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Help finding dictionary's names
« Reply #7 on: March 04, 2015, 12:15:48 PM »
And thank you ronjonp!

This example also enlightened me on the use of mapcar and lambda :) .
I've seen them before in some examples and didn't quite understand how were they working together.
Glad to help :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC