Jump to content

LISP to move selected objects to a specified layer?


Dan Kitchens

Recommended Posts

Hi peoples,

 

I've got a new challenge: Is there a Lisp that moves selected objects to an exisitng, specified layer?

 

I want to be able to select objects on the screen, type in a short command, and they automatically go to a certain layer (let's call it "Layer 1").

 

Having looked everywhere on the net, I can't find anything similar, and I don't know enough AutoLISP to be able to write it myself...

 

Thank you in advance!

 

Dan

Link to comment
Share on other sites

There are lisp-free ways to do it within the program, you can use COPYTOLAYER. If you are sure you want to use lisp, then it looks like you may find your answer in the similar threads section at the bottom of this page.

Link to comment
Share on other sites

Hi Dadgad,

 

Thanks for your suggestions.

 

COPYTOLAYER won't work because I don't want to copy the objects, I want to move them to a specified layer.

As for the below threads, I've just taken another look, and I can't find anything.

 

Surely there is a Lisp out there somewhere.

Link to comment
Share on other sites

Hi Dadgad,

 

Thanks for your suggestions.

 

COPYTOLAYER won't work because I don't want to copy the objects, I want to move them to a specified layer.

As for the below threads, I've just taken another look, and I can't find anything.

 

Surely there is a Lisp out there somewhere.

 

CHANGE command or PROPERTIES. Or you could write a script or action recorder macro.

Have you checked on Lee Mac's website, I bet he has something that will do that.

Edited by Dadgad
Link to comment
Share on other sites

That's the ticket, never used that one, good call! I would do it in my quick properties palette, which is always open. :winner: :beer:

Link to comment
Share on other sites

Thanks all for your input. The LAYMCH does work, but I find it too slow. My prop. palette is always closed so I can maximise working space, and it takes too long to open to be of any use.

 

The good news is that I found a Lisp at another site:

 

http://www.theswamp.org/index.php?topic=33195.0

 

The code reads: -

 

; Changes selected objects to Layer PL1
(defun c:setpl1 ()
 (command "_.chprop"
   (ssget ) "" "LA" "PL1" "")
        )

 

 

Thanks to memerson for that one. And thank you all for your help.

 

Dan

Edited by SLW210
Let's use CODE TAGS next time!!!!!!
Link to comment
Share on other sites

Glad you got it sorted, I hate the Properties palette, I find it to be a total nightmare. I love the QUICK PROPERTIES palette which is customizable and can be as small as you want it, and gets you all the info you need, on the fly, no waiting. :beer:

Link to comment
Share on other sites

Version without use of commands (works more quickly). If the layer with such name does not exist, it is created

; Changes selected objects to Layer PL1
(defun c:setpl1 ()
 (tolayer
   (ssget "_:L") ;;selection
   "PL1"         ;;Layer
   )
 (princ)
)
(defun tolayer ( ss lay / i e )
 ;;; ss - pickset
 ;;; lay -layer name
 (repeat (setq i (sslength ss))
   (entmod
     (subst
       (cons 8 lay)
       (assoc 8 (entget (setq e (ssname ss (setq i (1- i))))))
       (entget e)
       )
     )
   )
 )

  • Like 1
Link to comment
Share on other sites

Why not just select your objects, select the Layer Drop-down and choose the layer; the objects will be moved to the layer you select:

 

[ATTACH]33524[/ATTACH]

 

Lee Mac it always does my heart good to see one as gifted at programming as you offer a native solution. As one who is not lisp-savvy, and would love to be, I never cease to be amazed by the depth of automation to which some folks aspire. More power to them. My attitude is, if it works, don't fix it. :beer:

Link to comment
Share on other sites

Thank you Dadgad :)

 

I agree that many requests on this forum are attempting to reinvent existing AutoCAD functionality, but I suppose it also depends on how often the user is changing objects to a particular layer and how many layers exist in the drawing. Perhaps the OP is changing the same objects to a particular layer many times over in a drawing that contains hundreds of layers... at that point, I would also look to automate the procedure.

 

Well, at least he/she has many options now.

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...