Jump to content

Change current layer and selection set to layer 0..


Recommended Posts

Posted

Hi All,

 

I want a quick LISP command to change the current layer to 0 but not just do that, i want to be able to select objects first to change, so it changes all selected objects and the drawing's current layer to 0. I've tried this code out but it won't work (not the changing slected objects bit anyway)....any ideas on what i'm doing wrong or a better solution to my code?

 

; SET OBJECTS AND CURRENT LAYER TO 0..
(defun C:00 ()
 (setq a (cadr (ssgetfirst)))  
 (if a (command "-LAYER" "S" " " a "S" "0" ""))
 (princ)
)

Thanks,

Posted (edited)

oops.. wrong thread

 

anyhoo...:D

 

Edit: I was called away when i was about to reply to another thread but somebody mess with my station.. serves me right not locking my desktop

Edited by pBe
Posted

maybe:

[b][color=BLACK]([/color][/b]defun c:oo [b][color=FUCHSIA]([/color][/b]/ ss[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]not ss[b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSelect Entites To Change To Layer 0"[/color][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.LAYER"[/color] [color=#2f4f4f]"_UNlock"[/color] [color=#2f4f4f]"0"[/color] [color=#2f4f4f]"_Thaw"[/color] [color=#2f4f4f]"0"[/color] [color=#2f4f4f]"_ON"[/color] [color=#2f4f4f]"0"[/color] [color=#2f4f4f]"_Set"[/color] [color=#2f4f4f]"0"[/color] [color=#2f4f4f]""[/color]
          [color=#2f4f4f]"_.CHPROP"[/color] ss [color=#2f4f4f]""[/color] [color=#2f4f4f]"_LA"[/color] [color=#2f4f4f]"0"[/color] [color=#2f4f4f]""[/color][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

I wouldn't recommend using numeric characters ( if that is what they are ) as the leading character or all characters in a function name. I couldn't tell if they were zeros or the letter O. -David

Posted

Or if you want to use the pre-selection:

(defun C:00 (/ a)
 (if (setq a (cadr (ssgetfirst)))
   (command "_.change" a "" "_Properties" "_LAyer" "0" "")
 )
 (command "_.LAYER" "_Set" "0" "")
 (princ)
)

Posted

#3 + #4 = #5 :)

(defun C:00 ( / ss)
 (if (or (setq ss (cadr (ssgetfirst)))
         (and (princ "\nSelect Entites To Change To Layer 0")
              (setq ss (ssget "_:L"))
              )
         )
   (command "_.LAYER" "_UNlock" "0" "_Thaw" "0" "_ON" "0" "_Set" "0" ""
          "_.CHPROP" ss "" "_LA" "0" "")
 )
 (princ)
)

  • 2 years later...
Posted

Thanks so much for this! Sometimes the littlest things just drive me mad and eat my time. Thanks for this. :D

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