Jump to content

Need some help with CLAYER not being restored


Recommended Posts

Posted
(defun c:DC ( / curlay)
  (setq curlay (getvar "CLAYER"))
  (command
    "_.layer" "_set" "S - DETAIL CUT" ""
    "_.insert" "Detail Cut" "_scale" 36
    "_.layer" "_set" curlay ""
    )
)

 

 

After the block is inserted on the proper layer per the code, the layer is not being reset properly to the previous current layer.

 

Any help would be appreciated, I'm still learning lisp

 

 

Posted

Give this a try:

 

(defun c:DC ( / curlay)
  (setq curlay (getvar "CLAYER"))
  (setvar "clayer" "S - DETAIL CUT")
  (vl-cmdf "._insert" "Detail Cut" "_s" 36.0 "_r" 0)
  (setvar "clayer" curlay)
  (princ)
)

 

  • Like 2
Posted
On 9/16/2023 at 12:40 PM, rkmcswain said:

Give this a try:

 

(defun c:DC ( / curlay)
  (setq curlay (getvar "CLAYER"))
  (setvar "clayer" "S - DETAIL CUT")
  (vl-cmdf "._insert" "Detail Cut" "_s" 36.0 "_r" 0)
  (setvar "clayer" curlay)
  (princ)
)

 

 

 

I tried your solution but the layer is not reset to curlay properly.

 

I managed to find in a fix for my code by adding a pause after the rotate. see below; 

 

(defun c:DC ( / curlay)
  (setvar 'cmdecho 0)
  (setq curlay (getvar "CLAYER"))
    (command
    "_.layer" "_set" "S - DETAIL CUT" ""
    "_.insert" "Detail Cut" "_scale" 36 "_rotate" 0 pause
    "_.layer" "_set" curlay ""
    )
  (setvar 'cmdecho 1)
(Princ)
)

 

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