Jump to content

Create a Layer and move ALL to that Layer


VinniB

Recommended Posts

Is there an easy way from the command prompt: to make a new layer and move ALL to that layer. I would be using a programable keyboard to run the commands.

thank you for your help

Vinni

Link to comment
Share on other sites

Perhaps a little overkill, but I had fun :)

 

(defun c:AlltoLayer ( / lay ss )
 ;; © Lee Mac 2010

 (while
   (progn
     (setq lay (getstring t "\nSpecify Layer Name: "))

     (cond
       ( (eq "" lay) )
       ( (tblsearch "LAYER" lay) nil )
       ( (entmakex
           (list
             (cons 0 "LAYER")
             (cons 100 "AcDbSymbolTableRecord")
             (cons 100 "AcDbLayerTableRecord")
             (cons 2 lay)
             (cons 70 0)
           )
         )
        nil
       )
       ( (princ "\n** Invalid Layer Name **") )
     )
   )
 )

 (if (setq ss (ssget "_X" '((0 . "~VIEWPORT"))))
   (ApplyFootoSS
     (lambda ( x )
       (entupd
         (cdr
           (assoc -1
             (entmod
               (subst
                 (cons 8 lay) (assoc 8 (entget x)) (entget x)
               )
             )
           )
         )
       )
     )
     ss
   )
 )
 
 (princ)
)
   
(defun ApplyFootoSS ( foo ss )
 ;; © Lee Mac 2010
 (
   (lambda ( i / e )
     (while (setq e (ssname ss (setq i (1+ i)))) (foo e))
   )
   -1
 )
)

Link to comment
Share on other sites

Hmmmm. I get

; error: bad argument type: lselsetp nil

 

[ATTACH]21511[/ATTACH]

 

:?:

 

I tested in both 2004 & 2009. It worked great.

Link to comment
Share on other sites

Hmmmm. I get

; error: bad argument type: lselsetp nil

:?:

 

Sorry Rk, I can't seem to get it to fail - even with nothing in the drawing :(

Link to comment
Share on other sites

Of course, I overlooked the fact that you cannot entmod a Viewport... - quick workaround posted in previous code post.

 

I hate to point this out, but now it doesn't meet the original objective of the OP. o:)

Link to comment
Share on other sites

I hate to point this out, but now it doesn't meet the original objective of the OP. o:)

 

You could accomplish it using VL, but I can't be bothered to rewrite it :wink:

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