Author Topic: DXF Code for Plot Style Name?  (Read 7343 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: 12914
  • 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: 12914
  • 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