TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Sam on July 31, 2018, 11:49:16 AM

Title: Layer Create with IF and Progn
Post by: Sam on July 31, 2018, 11:49:16 AM
Dear sir,
i am looking create a layer if not found in drawing and its already in drawing the continue the program
confusion in this code its required progn or not

Code: [Select]
;----------------- Create layer if not found layer in drawing or its found the layer continue the program (opt-1)
(If (Null Mytextlayer)                                                          ;If Start
 (Progn (Setq (Mytextlayer "MYTEXT")                                            ;Layer is MYTEXT
              (Setq txlayer (Tblsearch "layer" Mytextlayer))                    ;Search in layer table
              (If (Null txlayer)                                                ;If not found MYTEXT Layer
               (Progn (Setq Mytextlayer ()                                      ;confusion this line is required or not
                            (Command "layer" "m" mytextlayer ""))               ;create layer MYTEXT
                      )))))
                ;If already layer its exist, then continue the program





                           
Title: Re: Layer Create with IF and Progn
Post by: ronjonp on July 31, 2018, 12:07:25 PM
Maybe:
Code: [Select]
(defun _makelayer (Mytextlayer)
  (or (Tblsearch "layer" Mytextlayer)
      (Command "layer" "m" mytextlayer "")
  )
)


There is also THIS (http://www.theswamp.org/index.php?topic=37230.msg422177#msg422177) from many moons ago.
Title: Re: Layer Create with IF and Progn
Post by: JohnK on July 31, 2018, 04:40:26 PM
Coincidence: I just posted a routine to something like this.
http://www.theswamp.org/index.php?topic=54354.msg589227#msg589227
Title: Re: Layer Create with IF and Progn
Post by: Sam on August 01, 2018, 02:06:05 AM
dear sir jhon
i look at same code thanks

and ron sir,
Thanks