Jump to content

Help: Lisp to move objects from layer zero


cadmano

Recommended Posts

I am extremely new to lisp and trying to learn on my own. (by the way this site has been incredible help! Thanks!)

 

Can someone please help me. I am trying to figure out how to grab all objects from layer "0" and move it to a new layer called "Old_0".

Link to comment
Share on other sites

Here is one way.

 

[color=blue][font="Courier New"]
(defun C:mvlay ( / sset)
 [color="green"]; if the layer OLD_0 does not exist, then create it (i am making it blue)[/color]
 (if (not (tblsearch "LAYER" "OLD_0"))
   (command "._LAYER" "_N" "OLD_0" "_C" "5" "OLD_0" "" "")
 )
 [color="green"]; grab everything on layer 0[/color] 
 (setq sset (ssget "_X" '((8 . "0"))))
[color="green"]  ; change it to layer OLD_0[/color]
 (command "._change" sset "" "_P" "_LA" "OLD_0" "")
 (princ)
)
[/font][/color]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...