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

0 Members and 1 Guest are viewing this topic.

Ben Clark

  • Newt
  • Posts: 94
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: 12906
  • 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"))))

Ben Clark

  • Newt
  • Posts: 94
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

  • Gator
  • Posts: 2507
  • 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

  • Swamp Rat
  • Posts: 812
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. )
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

Lee Mac

  • Seagull
  • Posts: 12906
  • 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

  • Gator
  • Posts: 2507
  • 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

ahsattarian

  • Newt
  • Posts: 112
Re: List of Visual Styles in DWG
« Reply #7 on: December 21, 2021, 03:26:56 PM »
Is there any way to activate them as well ????