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

0 Members and 1 Guest are viewing this topic.

Lee Mac

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