TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: youainta on November 12, 2021, 11:58:44 PM

Title: PlotStyle
Post by: youainta on November 12, 2021, 11:58:44 PM
I've come to understand that a lisp routine is basically a puzzle made up of puzzle pieces. Groups of code are the puzzle pieces and a functioning lisp routine, the puzzle. That being said, I haven't been able to figure out plotstyle. Using entmake to create a layer tells me that the 390 dxf code for plotstyle is a hard pointer to id handle, which doesn't sound like can be set.

I've tried to follow this post http://www.theswamp.org/index.php?topic=45131.msg503425#msg503425 (http://www.theswamp.org/index.php?topic=45131.msg503425#msg503425) as well as I can.

My question is how can I assign a plotstyle to a layer I'm creating? And how does that tie in to entmake?
Title: Re: PlotStyle
Post by: Lee Mac on November 13, 2021, 07:06:52 AM
For an existing example, you may wish to refer to lines 497-503 of my Layer Director (http://lee-mac.com/layerdirector.html) application - essentially, you need to point DXF group 390 to the appropriate entry within the acad_plotstylename dictionary.
Title: Re: PlotStyle
Post by: youainta on November 17, 2021, 01:39:38 PM
What does too few arguments mean?

This is what I've put together:

Code: [Select]
(setq linelist '(("Cable Television" . "utilities.lin")
("Electrical" . "utilities.lin")
("Fiber Optics" . "utilities.lin")
("Fire_Line" . "utilities.lin")
("Gas_line" . "utilities.lin")
("Sewer_Line" . "utilities.lin")
("Storm Sewer" . "utilities.lin")
("Telephone" . "utilities.lin")
("OHE" . "utilities.lin")
("UGE" . "utilities.lin")
("Water" . "utilities.lin")
)
)
(foreach lin linelist
  (if (tblsearch "LTYPE" (car lin))
    (command ".-linetype" "load" (car lin) (cdr lin) "_Yes" "")
    (command ".-linetype" "load" (car lin) (cdr lin) "")
  )
)

(defun _layer (name plot color linetype lineweight plotstyle)
  (if (null (tblsearch "LAYER" name))
    (entmake
      (list
'(000 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
'(070 . 0)
(cons 002 name)
(cons 290 plot)
(cons 062 color)
(cons 006 linetype)
(cons 370 lineweight)
(cons 390 plotstyle)
  (if
    (and (= 'str (type pst))
(zerop (getvar 'pstylemode))
(setq
   dic (dictsearch (namedobjdict) "acad_plotstylename"))
(setq dic (dictsearch (cdr (assoc -1 dic)) pst))
    )
  )
)
      )
    )
  )

       

(defun c:test ( / )
 (foreach _layer
  '(
    ("newlay" 1 12 "Continuous" 100 "100-10")
   )
   (apply '_layer item)
 )
 (princ)
)

Note: Credit to whom credit is due.
Title: Re: PlotStyle
Post by: Lee Mac on November 17, 2021, 04:43:33 PM