Author Topic: Layer Create with IF and Progn  (Read 1128 times)

0 Members and 1 Guest are viewing this topic.

Sam

  • Bull Frog
  • Posts: 201
Layer Create with IF and Progn
« 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





                           
« Last Edit: July 31, 2018, 11:56:36 AM by Sam »
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

ronjonp

  • Needs a day job
  • Posts: 7446
Re: Layer Create with IF and Progn
« Reply #1 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 from many moons ago.

Windows 11 x64 - AutoCAD /C3D 2022

Custom Build PC

JohnK

  • Administrator
  • Seagull
  • Posts: 10158
Re: Layer Create with IF and Progn
« Reply #2 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
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

Sam

  • Bull Frog
  • Posts: 201
Re: Layer Create with IF and Progn
« Reply #3 on: August 01, 2018, 02:06:05 AM »
dear sir jhon
i look at same code thanks

and ron sir,
Thanks
 
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html