Jump to content

Command reactor not working for XATTACH command?


Aftertouch

Recommended Posts

Hello all,

 

I found the code below on the interwebs,

It forces text and hatch objects to a certain layer.

(Changes to the layer, makes object, changes back).

for some reason the XATTACH command does place the XREF on the wanted layer, but doesnt set my current layer back to the previous setting... Why does XATTACH act different than Text commands???

 

(prompt " \nLoad Only....Do NOT Run...")
(vl-load-com)

;****************************************
(vlr-command-reactor 
nil '((:vlr-commandWillStart . startCommand)))
(vlr-command-reactor 
nil '((:vlr-commandEnded . endCommand)))
(vlr-command-reactor 
nil '((:vlr-commandCancelled . cancelCommand)))
;******************************************************
(defun startCommand (calling-reactor startcommandInfo / 
	     thecommandstart)
(setq OldLayer (getvar "CLAYER"))
(setq thecommandstart (nth 0 startcommandInfo))
(cond
 ((= thecommandstart "XATTACH") (setvar "CLAYER" "4"))
 ((= thecommandstart "MTEXT") (setvar "CLAYER" "4"))
 ((= thecommandstart "DTEXT") (setvar "CLAYER" "4"))

((= thecommandstart "HATCH") (setvar "CLAYER" "6"))
((= thecommandstart "BHATCH") (setvar "CLAYER" "6"))
);cond
(princ)
);defun
;****************************************************

(defun endCommand (calling-reactor endcommandInfo / 
	   thecommandend)
(setq thecommandend (nth 0 endcommandInfo))
(cond
 ((= thecommandend "XATTACH") (setvar "CLAYER" OldLayer))
 ((= thecommandend "MTEXT") (setvar "CLAYER" OldLayer))
 ((= thecommandend "DTEXT") (setvar "CLAYER" OldLayer))
 ((= thecommandend "HATCH") (setvar "CLAYER" OldLayer))
 ((= thecommandend "BHATCH") (setvar "CLAYER" OldLayer))

);cond
(princ)
);defun
;********************************************************
(defun cancelCommand (calling-reactor cancelcommandInfo / 
	      thecommandcancel)
(setq thecommandcancel (nth 0 cancelcommandInfo))
(cond
 ((= thecommandcancel "XATTACH") (setvar "CLAYER" OldLayer))
 ((= thecommandcancel "MTEXT") (setvar "CLAYER" OldLayer))
 ((= thecommandcancel "DTEXT") (setvar "CLAYER" OldLayer))
 ((= thecommandcancel "HATCH") (setvar "CLAYER" OldLayer))
 ((= thecommandcancel "BHATCH") (setvar "CLAYER" OldLayer))
);cond
(princ)
);defun
;*********************************************************
(princ)

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