Jump to content

Recommended Posts

Posted

WHile i was waiting for some info i decieded to delve into my first reator.

the only problem is.

some thing is setting "oldlayer" to dim.

when it should be set to the layer i had before i ran the command.

i must be missing some thing any help would be great

(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 "dimdiameter") (setvar "CLAYER" "dim"))
 ((= thecommandstart "DIMALIGNED") (setvar "CLAYER" "dim"))
 ((= thecommandstart "DIMLINEAR") (setvar "CLAYER" "dim"))
 ((= thecommandstart "dimradius") (setvar "CLAYER" "dim"))
 ((= thecommandstart "dimangular") (setvar "CLAYER" "dim"))
);cond
(princ)
);defun
;****************************************************

(defun endCommand (calling-reactor endcommandInfo / thecommandend)
(setq thecommandend (nth 0 endcommandInfo))
(cond
 ((= thecommandend "dimdiameter") (setvar "CLAYER" OldLayer))
 ((= thecommandend "dimlinear") (setvar "CLAYER" OldLayer))
 ((= thecommandend "DIMLINEAR") (setvar "CLAYER" OldLayer))
 ((= thecommandend "dimradius") (setvar "CLAYER" OldLayer))
 ((= thecommandend "dimangular") (setvar "CLAYER" OldLayer))
 
);cond
(princ)
);defun
;********************************************************
(defun cancelCommand (calling-reactor cancelcommandInfo / Thecommandcancel)
(setq thecommandcancel (nth 0 cancelcommandInfo))
(cond
 ((= thecommandcancel "dimdiameter") (setvar "CLAYER" OldLayer))
 ((= thecommandcancel "dimlinear") (setvar "CLAYER" OldLayer))
 ((= thecommandcancel "DIMLINEAR") (setvar "CLAYER" OldLayer))
 ((= thecommandcancel "dimradius") (setvar "CLAYER" OldLayer))
 ((= thecommandcancel "dimangular") (setvar "CLAYER" OldLayer))
 );cond
(princ)
);defun
;*********************************************************
(princ) 

 

 

 

cheers flower

Posted

Hi

 

1. One reactor with three events is enough.

2. Two callback functions is enough.

3. You should create "dim" layer

4. You may use WCMATCH or MEMBER instead COND.

 

 

(vl-load-com)
(vlr-command-reactor nil '
  ((:vlr-commandWillStart . startCommand)
  (:vlr-commandEnded . endcancelCommand)
  (:vlr-commandCancelled . endcancelCommand))
 ); end vlr-command-reactor

(if(vl-catch-all-error-p
    (vl-catch-all-apply 'vla-Item
      (list(setq layerCol(vla-get-Layers
		     (vla-get-ActiveDocument
		       (vlax-get-acad-object)))) "dim")))
 (vla-Add layerCol "dim")
 ); end if

;******************************************************
(defun startCommand (calling-reactor startcommandInfo)
(setq OldLayer (getvar "CLAYER"))
 (if(wcmatch(car startcommandInfo)"DIM*")
   (setvar "CLAYER" "dim")
   ); end if
(princ)
);defun
;****************************************************

(defun endcancelCommand (calling-reactor endcommandInfo)
 (if(wcmatch(car  endcommandInfo)"DIM*")
   (setvar "CLAYER" OldLayer)
   ); end if 
(princ)
);defun

Posted

Thank heaps for you advice. but i suffered from the same problem...

But i remembered that reactors do not always follow set order of things, so it was changing to dim layer then seting oldlayer.

so to fix my solution if places it before the command begin, This worked only in one dwg, then it gave me errors

so i placed it at the top again. and that works only is some dwg.

IS their a solution to have it run first

 

thanks again,

 

 

(vl-load-com)
(vlr-command-reactor nil '
     ((:vlr-commandWillStart . startCommand)
     (:vlr-commandEnded . endcancelCommand)
     (:vlr-commandCancelled . endcancelCommand))
 ); end vlr-command-reactor

(if(vl-catch-all-error-p
    (vl-catch-all-apply 'vla-Item
      (list(setq layerCol(vla-get-Layers
                (vla-get-ActiveDocument
                  (vlax-get-acad-object)))) "dim")))
 (vla-Add layerCol "dim")
 [color=Red](setq OldLayer (getvar "CLAYER"))[/color]
 ); end if

;******************************************************
(defun startCommand (calling-reactor startcommandInfo)
[color=Lime](setq OldLayer (getvar "CLAYER"))[/color]
(if (= 1 (getvar "dimlfac"))
 (setvar "dimclrt" 2)
 (setvar "dimclrt" 3)
 )
 (if(wcmatch(car startcommandInfo)"DIM*")
   (setvar "CLAYER" "dim")
   ); end if
(princ)
);defun
;****************************************************

(defun endcancelCommand (calling-reactor endcommandInfo)
 (if(wcmatch(car  endcommandInfo)"DIM*")
   (setvar "CLAYER" OldLayer)
   (setvar"dimclrt" 2)
   ); end if 
(princ)
);defun

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