Author Topic: List of Visual Styles in DWG  (Read 219 times)

0 Members and 1 Guest are viewing this topic.

barnjart42

  • Mosquito
  • Posts: 10
List of Visual Styles in DWG
« on: April 14, 2017, 10:33:23 am »
My last post went unanswered. So as a result of doing my own fishing, I've boiled it down to an easier one  :-D. I still don't understand dictionaries well though.

I need a function that outputs a list of all the visual styles in the drawing (so that I can check for the existence of a certain visual style).

Anybody have a way to do this?

Lee Mac

  • Seagull
  • Posts: 11732
  • AutoCAD 2015 Windows 7 London, England
Re: List of Visual Styles in DWG
« Reply #1 on: April 14, 2017, 10:37:43 am »
Simple example:
Code - Auto/Visual Lisp: [Select]
  1. (defun dictnames ( dic / itm rtn )
  2.    (while (setq itm (dictnext dic (null itm)))
  3.        (setq rtn (cons (cdr (assoc 2 itm)) rtn))
  4.    )
  5. )
Code - Auto/Visual Lisp: [Select]
  1. (dictnames (cdr (assoc -1 (dictsearch (namedobjdict) "acad_visualstyle"))))

barnjart42

  • Mosquito
  • Posts: 10
Re: List of Visual Styles in DWG
« Reply #2 on: April 14, 2017, 10:41:38 am »
Lee, worked like a charm. Thank you so much!

Know of a good source out there that I could check out that would give me a good handle on the namedobjdict?

gile

  • Water Moccasin
  • Posts: 2080
  • Marseille, France
Re: List of Visual Styles in DWG
« Reply #3 on: April 14, 2017, 10:55:31 am »
Hi,

It might be interesting to get a list of (entryKey . ename) pairs for each entry in a dictionary

Code - Auto/Visual Lisp: [Select]
  1. (defun getDictEntries (lst)
  2.  (if (setq lst (member (assoc 3 lst) lst))
  3.    (cons (cons (cdar lst) (cdadr lst)) (getDictEntries (cddr lst)))
  4.  )
  5. )

Code - Auto/Visual Lisp: [Select]
  1. (getDictEntries (dictsearch (namedobjdict) "acad_visualstyle"))
Speaking English as a French Frog

Grrr1337

  • Bull Frog
  • Posts: 338
Re: List of Visual Styles in DWG
« Reply #4 on: April 14, 2017, 11:05:48 am »
It might be interesting to get a list of (entryKey . ename) pairs for each entry in a dictionary

Cool idea, gile!
Heres a sample result:

Code - Auto/Visual Lisp: [Select]
  1. _$ (getDictEntries (entget (namedobjdict)))
  2. (("ACAD_CIP_PREVIOUS_PRODUCT_INFO" . <Entity name: 7ff6b14049e0>)
  3.  ("ACAD_COLOR" . <Entity name: 7ff6b1403bb0>)
  4.  ("ACAD_DETAILVIEWSTYLE" . <Entity name: 7ff6b1404a30>)
  5.  ("ACAD_GROUP" . <Entity name: 7ff6b14038d0>)
  6.  ("ACAD_LAYOUT" . <Entity name: 7ff6b14039a0>)
  7.  ("ACAD_MATERIAL" . <Entity name: 7ff6b1403ba0>)
  8.  ("ACAD_MLEADERSTYLE" . <Entity name: 7ff6b1404150>)
  9.  ("ACAD_MLINESTYLE" . <Entity name: 7ff6b1403970>)
  10.  ("ACAD_PLOTSETTINGS" . <Entity name: 7ff6b1403990>)
  11.  ("ACAD_PLOTSTYLENAME" . <Entity name: 7ff6b14038e0>)
  12.  ("ACAD_SCALELIST" . <Entity name: 7ff6b14040c0>)
  13.  ("ACAD_SECTIONVIEWSTYLE" . <Entity name: 7ff6b1404a10>)
  14.  ("ACAD_TABLESTYLE" . <Entity name: 7ff6b1403c60>)
  15.  ("ACAD_VISUALSTYLE" . <Entity name: 7ff6b1403ef0>)
  16.  ("AcDbVariableDictionary" . <Entity name: 7ff6b1403ae0>)
  17. )

Lee Mac

  • Seagull
  • Posts: 11732
  • AutoCAD 2015 Windows 7 London, England
Re: List of Visual Styles in DWG
« Reply #5 on: April 14, 2017, 11:16:32 am »
gile, is there any advantage to retrieving dictionary entries using a list iterator as opposed to using dictnext which is designed for this purpose? i.e.:

Code - Auto/Visual Lisp: [Select]
  1. (defun dictenames ( dic / itm rtn )
  2.    (while (setq itm (dictnext dic (null itm)))
  3.        (setq rtn (cons (cons (cdr (assoc 2 itm)) (cdr (assoc -1 itm))) rtn))
  4.    )
  5. )

gile

  • Water Moccasin
  • Posts: 2080
  • Marseille, France
Re: List of Visual Styles in DWG
« Reply #6 on: April 14, 2017, 11:27:55 am »
I do not think there's any advantage (neither any disadvantage), it's just an old one I had in a library.
Speaking English as a French Frog