• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

creates list of certain layers

  • Thread starter Thread starter zintonio
  • Start date Start date

zintonio

Guest
Hello.
I would like to create the list of certain layers and I sketched a lisp function but it doesn't work maybe wrong something. the lisp that I sketched is as follows:
(defun c:clistalayer (/ listlayer layer)
(setq entlayer (tblnext "layer" t)
(sing)
(progn)
(setq layer)
(if) (substr layer 1 1) "d")
(setq listlayer)
)
)
)
(setq listlayer listlayer)
)
It's like I'm in the while and it's gone.
My goal is to create a list of all layers whose name starts for example (d1, d2, etc.)
Thank you.
 
(defun c:clistalayer (/ listalayer layer)
(setq layer (cdr (assoc 2 (tblnext "layer" t))))
(while (/= layer nil)
(setq layer (cdr (assoc 2 (tblnext "layer"))))
(if
(and
(/= layer nil)
(= (substr layer 1 1) "d")
)
(setq listalayer (append listalayer (list layer)))
)
)
)

il lisp cattura solo i layer che iniziano con "d", se vuoi anche quelli che iniziano con "d" scrivi così:

(= (strcase (substr layer 1 1)) "d")

:smile::smile::smile:
 
thanks a thousand gp:finger: excellent lisp.
I added to the end:
(setq l (length listlayer)
(prin1 listlayer)
(prin1 l)
to see the result.
 
I wanted to ask you something to better understand the lisp language.
I tried to paste the following list on the command bar:
(setq layer (cdr (assoc 2)))
;(setq listlayer '(nil))
(while (/= layer nil)
(setq layer)
(f)
(sing)
(/= layer nil)
(d)
)
(setq listlayer)
)
)
(setq l (length listlayer)
(prin1 listlayer)
(prin1 l)

and I get out the n-uplicate list so many times as I cover and take off.
But if I run the function, it's okay.

I was wondering, then, what resets the variables.....maybe defunct c: somehow deletes the content of the variables?
Thank you.
 
indicating
(defun c:clistalayer (/ listalayer layer)
make the "local" variable, therefore not usable outside the function as it resets to "nil".

do not insert it into the defunct, make it "global" and then maintain its value even at the exit from the lisp, try to type !listalayer by command.

I don't know if you already do it, but you better use the visuallisp editor for your changes, you can also select only a part of code and try "the effect it does", from command -> vlisp.
 
thanks gp now is clearer.:finger:
always about this lisp (crealistalayer) known that the layers are not sorted so I would like to reorder them by name and I have inserted functions that try to order them but without any result. to reorder them I used the bubblesort function. place the lisp so you understand better.
Thank you.
 

Attachments

great:finger:
on the use of visual lisp, I tried to open the lisp in the editor.
to try some parts of code I have to click with the right and press analyze?
or is there a run button? I've never used the visual editor so I'm a bit disoriented as soon as I opened it.
Are there any methods to create lisp or do I have to edit them?
Thank you.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top