Author Topic: DXF Code for Plot Style Name?  (Read 7506 times)

0 Members and 1 Guest are viewing this topic.

cadman6735

  • Guest
DXF Code for Plot Style Name?
« on: August 14, 2013, 12:06:40 PM »
Is there a DXF code for a layer plotstyle name?

all my searches result in VisualLisp, I am curious about vanilla...

thanks

BlackBox

  • King Gator
  • Posts: 3770
Re: DXF Code for Plot Style Name?
« Reply #1 on: August 14, 2013, 12:18:26 PM »
Quote

Group Codes in Numerical Order

380-389

PlotStyleName type enum (AcDb::PlotStyleNameType). Stored and moved around as a short. Custom non-entity objects may use the full range, but entity classes only use 381-389 DXF group codes in their representation, for the same reason as the Lineweight range above.
"How we think determines what we do, and what we do determines what we get."

cadman6735

  • Guest
Re: DXF Code for Plot Style Name?
« Reply #2 on: August 14, 2013, 12:36:16 PM »
thanks blackbox

I was looking under tables, Layer....  surprisingly it is not there


How do I set the plot style name via vanilla?

Code: [Select]
(defun c:test ( / )

  (entmake (list (cons 0 "LAYER")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbLayerTableRecord")
(cons 2 "G-ANNO-SEAL")
(cons 70 0)
(cons 62 7)
(cons 6 "Continuous")
(cons 290 1)
;(cons 370 0)
(cons 389 "As Drawn")
   )
  )

(princ)
)


I have tried all the number 380-389??? 
Thanks again

BlackBox

  • King Gator
  • Posts: 3770
Re: DXF Code for Plot Style Name?
« Reply #3 on: August 14, 2013, 12:47:36 PM »
How do I set the plot style name via vanilla?

Getting, and Setting are not always equal... I suspect that this is possible, although I'm going to have to dig into it a bit more, as it appears that DXF 390 is a hard-pointer ID (handle) tot he plot style object.
"How we think determines what we do, and what we do determines what we get."

cadman6735

  • Guest
Re: DXF Code for Plot Style Name?
« Reply #4 on: August 14, 2013, 01:05:26 PM »
Yeah, I dug into 390, I didn't know what I was looking at...

Code: [Select]
(defun c:test ( / )

  (setq tb (entget (tblobjname "LAYER" "0")))

  (setq ps (entget (cdr (assoc 390 tb))))

  ;(print tb)
  (print ps)

(princ)
)

Result:

Command: test
((-1 . <Entity name: 7ffff703870>) (0 . "ACDBPLACEHOLDER") (5 . "7") (102 . "{ACAD_REACTORS") (330 . <Entity name: 7ffff703880>) (102 . "}") (330 . <Entity name: 7ffff703880>))


Thanks for any help you can throw my way...  I have no issue to solve, just trying to learn...


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: DXF Code for Plot Style Name?
« Reply #5 on: August 14, 2013, 01:23:26 PM »
All I have is vlisp

I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: DXF Code for Plot Style Name?
« Reply #6 on: August 15, 2013, 09:48:48 AM »
... Or if you want to use 'classic' Lisp only:
Code - Auto/Visual Lisp: [Select]
  1.   (member
  2.     (cons 350 (cdr (assoc 390 layerElist)))
  3.     (reverse (dictsearch (namedobjdict) "ACAD_PLOTSTYLENAME"))
  4.   )
  5. )

cadman6735

  • Guest
Re: DXF Code for Plot Style Name?
« Reply #7 on: August 15, 2013, 01:12:06 PM »
Roy,
It took me a minute to understand where you got the DXF 350 code from...

Code: [Select]
(mapcar 'print (entget (namedobjdict)))
low and behold the 350 and a list of dictionaries...  So this opens a door for me, thanks...

What is "cdadr"

do you or somebody have a list of CAR CDR and what they all mean?  I found this:
http://www.austincc.edu/sgideon/fctnlist.html

and other websites that basicly say the same thing but not much detail

All concatenations of CAR and CDR supported by AutoLISP:

caaaar cadaar cdaaar cddaar
caaadr cadadr cdaadr cddadr
caaar cadar cdaar cddar
caadar caddar cdadar cdddar
caaddr cadddr cdaddr cdddddr
caadr caddr cdadr cdddr
caar cadr cdar cddr


I am trying to figure out how to entmod the layer plotstyle but am stuck on how you got where you got and think understanding this "cdadr" will help me move forward...

thanks

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: DXF Code for Plot Style Name?
« Reply #8 on: August 15, 2013, 01:19:15 PM »
What is "cdadr"

do you or somebody have a list of CAR CDR and what they all mean?

This might help:
http://www.theswamp.org/index.php?topic=39025.msg442238#msg442238

cadman6735

  • Guest
Re: DXF Code for Plot Style Name?
« Reply #9 on: August 15, 2013, 02:23:07 PM »
Thank you for the link Lee
This is my current understanding...

If I look at the entire list I get:
Quote
((350 . <Entity name: 7ffff0ea870>) (3 . "As drawn") (350 . <Entity name: 7ffff0dcf40>) (3 . "90% Screen") (281 . 1) (280 . 0) (100 . "AcDbDictionary") (330 . <Entity name: 7ffff0ea890>) (102 . "}") (330 . <Entity name: 7ffff0ea890>) (102 . "{ACAD_REACTORS") (5 . "8") (0 . "ACDBDICTIONARYWDFLT") (-1 . <Entity name: 7ffff0ea880>))

cdadr =

c(d)adr = skip the first element of list, return remainder of list
Quote
((3 . "As drawn") (350 . <Entity name: 7ffff0dcf40>) (3 . "90% Screen") (281 . 1) (280 . 0) (100 . "AcDbDictionary") (330 . <Entity name: 7ffff0ea890>) (102 . "}") (330 . <Entity name: 7ffff0ea890>) (102 . "{ACAD_REACTORS") (5 . "8") (0 . "ACDBDICTIONARYWDFLT") (-1 . <Entity name: 7ffff0ea880>))
cd(a)dr = return first element of list from the remaining list above
Quote
3 . "As drawn"
cda(d)r = skip the first element of the list returned from above
Quote
"As drawn"

and if I am correct in the above, I think I will go home for the day...


roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: DXF Code for Plot Style Name?
« Reply #10 on: August 15, 2013, 02:27:30 PM »
@ cadman6735:
If you want to use 'vanilla' to set the plot style for a layer there is an issue that you should take into account. The "ACAD_PLOTSTYLENAME" dictionary only contains references to styles that are currently in use in the drawing. Adding a plot style to the dictionary may be possible, but you would probably also have to create multiple interlinked entities.

To give you an idea of the entities involved:
Code - Auto/Visual Lisp: [Select]
  1. (entget (cdr (assoc 390 (entget (tblobjname "layer" "0")))))
  2. ; => "ACDBPLACEHOLDER"
  3. (entget (cdr (assoc 330 (entget (cdr (assoc 390 (entget (tblobjname "layer" "0"))))))))
  4. ; => "ACDBDICTIONARYWDFLT"

Using Vlisp is much easier:
Code - Auto/Visual Lisp: [Select]
  1. (vla-put-plotstylename layerObject plotStyleName)

cadman6735

  • Guest
Re: DXF Code for Plot Style Name?
« Reply #11 on: August 15, 2013, 02:47:05 PM »
Hi Roy, thank you for your help,

Quote
If you want to use 'vanilla'
It matters not to me, vanilla or VL...  I am only learning how things work...  I am practicing how to access and change DXF codes and manipulate lists and such...  I have no objective other than to learn...  Visual lisp seems much easier to use but I get stuck on the basics so I focus more on vanilla lisp...

----------------------------------------------

Are you telling me that I can only read "ACAD_PLOTSTYLENAME" dictionary items with vanilla lisp and will need to use visual lisp to modify it?  If this is so, then I can see I need to move past this.

Thanks again...

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: DXF Code for Plot Style Name?
« Reply #12 on: August 15, 2013, 03:52:04 PM »
I usually find anything past (car ...), (cdr ...), and (cdar ...) to be less readable than a simple (car (nth index1 ....)).  (car ...) gets used a lot to pull the first item off a list/dotted pair.  (cdr ...) gets used in conjuction with that to create a collapsing list procedure ie.

Code: [Select]
(setq cur_item (car temp_list))

...

(setq tlist (cdr tlist))
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: DXF Code for Plot Style Name?
« Reply #13 on: August 15, 2013, 04:11:41 PM »
c(d)adr = skip the first element of list, return remainder of list
Quote
((3 . "As drawn") (350 . <Entity name: 7ffff0dcf40>) (3 . "90% Screen") (281 . 1) (280 . 0) (100 . "AcDbDictionary") (330 . <Entity name: 7ffff0ea890>) (102 . "}") (330 . <Entity name: 7ffff0ea890>) (102 . "{ACAD_REACTORS") (5 . "8") (0 . "ACDBDICTIONARYWDFLT") (-1 . <Entity name: 7ffff0ea880>))
cd(a)dr = return first element of list from the remaining list above
Quote
3 . "As drawn"
cda(d)r = skip the first element of the list returned from above
Quote
"As drawn"

Not quite...

The result from your dissection is only correct because the particular c*r function in this case is 'symmetrical'.

Remember:
  • LISP evaluates from the inside out.
  • The c*r functions are a contraction of multiple car & cdr expressions.

Now, for the example in question:

Let's use a simplified list for convenience (the values are irrelevant, all that matters is that the list structure is the same):
Code - Auto/Visual Lisp: [Select]
  1. ((350 . "abc") (3 . "def") (350 . "ghi") (3 . "jkl"))

Now consider that cdadr is a contraction of multiple car & cdr expressions, specifically:
Code - Auto/Visual Lisp: [Select]
  1. (cdadr <list>) == (cdr (car (cdr <list>)))
(Note the symmetry for this particular example, as stated above)

Hence, for our list:
Code - Auto/Visual Lisp: [Select]
  1.   (cdadr ((350 . "abc") (3 . "def") (350 . "ghi") (3 . "jkl")))
  2. = (cdr (car (cdr ((350 . "abc") (3 . "def") (350 . "ghi") (3 . "jkl")))))
  3. = (cdr (car ((3 . "def") (350 . "ghi") (3 . "jkl"))))
  4. = (cdr (3 . "def"))
  5. = "def"

Essentially, read the a's & d's from right to left.

So, as an example for the function cdaddr:

cdaddr
Code - Auto/Visual Lisp: [Select]
  1. (cdaddr '((1 . "A") (2 . "B") (3 . "C") (4 . "D")))

cdaddr:
Code - Auto/Visual Lisp: [Select]
  1. (cdadr '((2 . "B") (3 . "C") (4 . "D")))

cdaddr:
Code - Auto/Visual Lisp: [Select]
  1. (cdar '((3 . "C") (4 . "D")))

cdaddr:
Code - Auto/Visual Lisp: [Select]
  1. (cdr '(3 . "C"))

cdaddr:
Code - Auto/Visual Lisp: [Select]
  1. "C"

« Last Edit: August 15, 2013, 05:27:16 PM by Lee Mac »

cadman6735

  • Guest
Re: DXF Code for Plot Style Name?
« Reply #14 on: August 15, 2013, 05:14:38 PM »
Lee, you have an excellent way of explaining things...

Quote
Essentially, read the a's & d's from right to left.
was all I needed to understand then the example to confirm it...   amazing... thank you.

---------------------------------------------------------

Hi dgorsman,

Thanks you for sharing this
Quote
(car (nth index1 ....)). 
I have seen examples using "nth" and I have read about it but I have never used it, I haven't found a need yet but maybe now I have.

What is a collapsing lisp procedure, first time I have heard of this...
I am not sure what you are showing me in your example.


I ask one question and learn 2 other things, you guys are awesome....
Thanks

Lee Mac

  • Seagull
  • Posts: 12927
  • London, England
Re: DXF Code for Plot Style Name?
« Reply #15 on: August 15, 2013, 05:28:56 PM »
Lee, you have an excellent way of explaining things...

Quote
Essentially, read the a's & d's from right to left.
was all I needed to understand then the example to confirm it...   amazing... thank you.

Thank you cadman, I'm pleased that my explanations were comprehensible  :-)

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: DXF Code for Plot Style Name?
« Reply #16 on: August 16, 2013, 07:59:58 AM »
Are you telling me that I can only read "ACAD_PLOTSTYLENAME" dictionary items with vanilla lisp and will need to use visual lisp to modify it?  If this is so, then I can see I need to move past this.
If you want to change the plot style of a layer to a plot style that is already in use in the drawing then that would be doable (but not very easy) in 'vanilla'. Adding a new plot style using 'vanilla' would very hard and may even be impossible. I have never tried it.

...  I am only learning how things work...  I am practicing how to access and change DXF codes and manipulate lists and such...
If your goal is to learn more about (entmake) and (entmod) I would suggest starting with other entities and properties. Changing the color of graphical entities is a better starting point.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: DXF Code for Plot Style Name?
« Reply #17 on: August 16, 2013, 10:11:22 AM »
What is a collapsing lisp procedure, first time I have heard of this...
I am not sure what you are showing me in your example.

"Collapsing lisT" (emphasis on the T).    Sometimes I have to process a *very* large list in a way that I have to find something later in the list.  I could use (nth ...) to iterate over the entire list, but that can make for a very long search eg. 1st item, search against items 2 through n; 2nd item, search through items 1 and 3 through n; and so on.  Or I can try to manage a secondary index of where to start searching; that gets even worse if I have to start removing that matching element from the list.  Instead, on each pass I use (car ...) to get the first item in the list and (setq tlist (cdr tlist)) to set the working list as the remainder.  Since the list is shrinking (collapsing) with every cycle, each pass needs to process fewer and fewer items.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

cadman6735

  • Guest
Re: DXF Code for Plot Style Name?
« Reply #18 on: August 20, 2013, 09:49:19 AM »
Quote
If you want to change the plot style of a layer to a plot style that is already in use in the drawing then that would be doable (but not very easy) in 'vanilla'. Adding a new plot style using 'vanilla' would very hard and may even be impossible. I have never tried it.
Thanks Roy...

Quote
"Collapsing lisT" (emphasis on the T).    Sometimes I have to process a *very* large list in a way that I have to find something later in the list.  I could use (nth ...) to iterate over the entire list, but that can make for a very long search eg. 1st item, search against items 2 through n; 2nd item, search through items 1 and 3 through n; and so on.  Or I can try to manage a secondary index of where to start searching; that gets even worse if I have to start removing that matching element from the list.  Instead, on each pass I use (car ...) to get the first item in the list and (setq tlist (cdr tlist)) to set the working list as the remainder.  Since the list is shrinking (collapsing) with every cycle, each pass needs to process fewer and fewer items.
Thanks dgorsman for explaining to me your example.  This helps me very much...  and I find the NTH function very handy now I understand the CAR, CDR concatenations.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: DXF Code for Plot Style Name?
« Reply #19 on: August 23, 2013, 06:19:19 AM »
Are you telling me that I can only read "ACAD_PLOTSTYLENAME" dictionary items with vanilla lisp and will need to use visual lisp to modify it?  If this is so, then I can see I need to move past this.
If you want to change the plot style of a layer to a plot style that is already in use in the drawing then that would be doable (but not very easy) in 'vanilla'. Adding a new plot style using 'vanilla' would very hard and may even be impossible. I have never tried it.
I have to revise this opinion. Working with plot styles in 'vanilla' is possible and even adding a new style is not that hard. The code below works on BricsCAD V13.2.10 (I don't use 'the other product').

Code - Auto/Visual Lisp: [Select]
  1. ; Note: The code should only be used if PSTYLEMODE=0.
  2.  
  3. ; Return value: Ename of existing or new "ACDBPLACEHOLDER".
  4. (defun PlotStyleDwgGetOrAdd (plotStyleName / dictEname)
  5.   (setq dictEname (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_PLOTSTYLENAME"))))
  6.   (cond
  7.     ((cdr (assoc -1 (dictsearch dictEname plotStyleName))))
  8.     ((dictadd dictEname plotStyleName (entmakex '((0 . "ACDBPLACEHOLDER")))))
  9.   )
  10. )
  11.  
  12. ; Return value: Elist.
  13. ; The "ByBlock" and "ByLayer" values should (obviously) not be used for layers.
  14. (defun PlotStyleSet (ename plotStyleName / elist)
  15.   (setq elist (entget ename))
  16.   (setq elist
  17.     (vl-remove
  18.       (assoc 380 elist)
  19.       (vl-remove (assoc 390 elist) elist)
  20.     )
  21.   )
  22.   (entmod
  23.     (append ; Appending the new item is required for layers (BC 13.2.10).
  24.       elist
  25.       (list
  26.         (cond
  27.           ((= (strcase plotStyleName) "BYLAYER")
  28.             '(380 . 0)
  29.           )
  30.           ((= (strcase plotStyleName) "BYBLOCK")
  31.             '(380 . 1)
  32.           )
  33.           (T
  34.             (cons 390 (PlotStyleDwgGetOrAdd plotStyleName))
  35.           )
  36.         )
  37.       )
  38.     )
  39.   )
  40. )
  41.  
  42. ; Return value: Plot style name.
  43. (defun PlotStyleGet (ename / elist placeHolderEname)
  44.   (setq elist (entget ename))
  45.   (cond
  46.     ((setq placeHolderEname (cdr (assoc 390 elist)))
  47.       (cdadr
  48.         (member
  49.           (cons 350 placeHolderEname)
  50.           (reverse (dictsearch (namedobjdict) "ACAD_PLOTSTYLENAME"))
  51.         )
  52.       )
  53.     )
  54.     ((member '(380 . 1) elist)
  55.       "ByBlock"
  56.     )
  57.     (T
  58.       "ByLayer"
  59.     )
  60.   )
  61. )
  62.