TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: PM on July 14, 2021, 11:35:46 AM
-
Hi i have a layer with name "_3d points " and is off all the time in my drawings.I want some timew to delete it with all entities on it without goin to properties palen and quick select this layer and delete it. Is it possible to do this with a lisp?
Thanks
-
Do you want to select the objects(layer) on the screen or would you just like to delete the layer without any user interaction at all?
you can use the LAYDEL command (very low tech) but you have to be sure that the layer you want to delete isn't the current layer (you can set the current layer to ZERO to be safe).
(command "._layer" "t" "0" "on" "0" "s" "0" "") (laydel
"t" (ssget "x" '
((8 .
"_3d points"))) "yes")
-
Hi John Kaul (Se7en). I did it but gives me this message
(command "._layer" "t" "0" "on" "0" "s" "0" "") (laydel
"t" (ssget "x" '
((8 .
"_3d points"))) "yes") )
Select object on layer to delete or [Name]:
I turn the layer on and i run again the code but the same result. I can not understand . We allready give the name in the code
-
Oh sorry, I was interrupted while I was typing my response. We cannot use it that way. I intended to offer up two different concepts. One was using the SSGET to erase stuff on that layer and the other concept was to use LAYDEL. Sorry, my first post is incomprehensible and incomplete. I am very busy at the moment and trying to do too many things at once. But quickly...
You would use laydel something like this: (command "_laydel" "n" "_3d points" "" "yes")
You can get items on that layer to delete like this: (ssget "x" '((8 . "_3d points")))
You can get the layer entity like this:(tblobjname "layer" "_3d points")
-
with only this command
(command "_laydel" "n" "_3d points" "" "yes")
delete the layer with all entities on it without other code
-
yes, it should but you shouldn't just randomly delete layer without checking to see what the current layer is, for example (it will fail I believe). Investigate, then delete.
-
My take on it
(defun c:dellay ( / lay)
(setq lay (cdr (assoc 8 (entget (car (entsel "\nPick object for layer "))))))
(if (= lay (getvar 'clayer))
(command "._layer" "t" "0" "on" "0" "s" "0" "")
)
(command "-laydel" (ssget "x" (list (cons 8 Lay))) "" "yes")
(princ)
)
-
Since we already know the layer we'd like to remove. I would (at the very minimum):
1. Check if layer exists
1a. if so, then check to see if it is the current layer.
1b. if so, then change to another layer.
1c. delete the layer.
(command "._layer" "t" "0" "on" "0" "s" "0" "") )
(command "-laydel" "_3d points" "" "yes") )
)
)
)
-
Im confiused John Kaul (Se7en) .Can you fix the code ??
(command "._layer" "t" "0" "on" "0" "s" "0" "") )
)
)
Thanks
-
You're confused about what?
That code will not work so use the code I gave you instead.
-
Something like this ??
(command "._layer" "t" "0" "on" "0" "s" "0" "") )
(command "-laydel" "_3d points" "" "yes") )
)
)
)
-
gives me this result
#<SUBR @000001383de23368 -lambda->
-
Ah. I understand what you're confused about now.
You should read:
The Basics in a Nutshell - Part 1 (https://www.afralisp.net/autolisp/tutorials/the-basics-part-1.php)
The Basics in a Nutshell - Part 2 (https://www.afralisp.net/autolisp/tutorials/the-basics-part-2.php)
You can do this:
(command "._layer" "t" "0" "on" "0" "s" "0" "") )
(command "-laydel" "_3d points" "" "yes") )
)
)
)
)
or this:
(command "._layer" "t" "0" "on" "0" "s" "0" "") )
(command "-laydel" "_3d points" "" "yes") )
)
)
To answer your last post:
That is an expected result to your code because you told the interpreter to only create the lambda function, not execute it. That result is the location in memory where your lambda function exists.
-
why all the time ask
Select object on layer to delete or [Name]:
This layer is all the time off and i want to delete it anyway with all entities on it
when i use
(command "_laydel" "n" "_3d points" "" "yes")
delete evetything without questions
-
Oh?! That is because "-laydel" is a typo! Use "_laydel".