Jump to content

Recommended Posts

Posted

Hey guys,

 

The other day I switched machines at work, I am now using Windows & (64bit) with AutoCAD 2012 (+ ProSteel). Since making the leap... I have noticed that there is something (my guess is that a LISP routine is the culprit) is altering my DIMSCALE sysvar... setting it to 1.

 

So... I'm just wondering if you guys have any suggestions on how I might be able to identify which routine might be guilty... Is there a way to see/track which routines are responsible for setting SYSVARs? Is it possible that my current DWG is inheriting the DIMSCALE value from any other blocks I insert? Or something more obscure?

 

I look forward to hearing back, thanks a lot for any help.

Posted

Try using a SysVar Reactor to prompt you at the command line when the desired variable(s) have changed... This should allow you to 'see' what Command/LISP routine you've just executed.

Posted

Hi BlackBox,

 

Thanks heaps for taking the time to reply. Up until now... I had never heard of SysVar Reactors, but they sound pretty handy.

 

Do you suggest something along these lines:

 

(defun C:ALERTME ()
(vl-load-com)
(setq VTFRXN
(vlr-editor-reactor nil
'((:VLR-sysVarChanged . VTF)
)
)
)
)
(defun VTF (CALL CALLBACK)
(princ
(strcat
(strcase
(car CALLBACK)
)
" has been changed! ")
)
)

 

Taken from: http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Running-Changes-in-System-Variables/td-p/2200079

 

... Or something else? Ideally I'd include and alert function to enable a popup tp bug me at least until I discover the offending routine.

 

I'm afraid I won't be able to test anything until work tomorrow (approx 10 hours), but you have indeed given me great hope.

 

Thanks again.

Posted

Reactors can be tricky :thumbsup:; with them more so than common 'brute force' routines with Command calls, etc. because the code-behind for Command calls handles most errors, etc., whereas if you were to invoke the code you posted above twice, you'd end up with two reactors, and so on.

 

This thread has an example of how I'd have coded a SysVar reactor to 'target' a particular variable... If you're experiencing this frequently (with other system variables), it might be prudent to enhance the code to prompt the user for a list of system variables as WCMATCH string to 'watch' (i.e., "CMDECHO,NOMUTT"), otherwise here's a general routine I used to use when I first started getting into reactors which catches all exposed system variable changes:

 

(vl-load-com)

(defun c:SysVarWatch (/ sysvar)
 (princ "\rSYSVARWATCH = ")

 (if *Reactor_SysVar*
   (progn                                                              ; Turn off
     (vlr-remove *Reactor_SysVar*)
     (setq *Reactor_SysVar* nil)
     (setq Callback:SysVarChanged nil)
     (princ "OFF ")
   )

   (progn                                                              ; Turn on
     (or *Reactor_SysVar*
         (setq *Reactor_SysVar*
                (vlr-sysvar-reactor
                  "SysVarWatch"
                  '(
                    (:vlr-sysvarchanged . Callback:SysVarChanged)
                   )
                )
         )
     )

     (defun Callback:SysVarChanged (rea var)
       (if (= T (cadr var))
         (prompt
           (strcat "\n[sysVarWatch] : System Var Changed \t\t  : "
                   (setq sysvar (strcase (car var)))
                   " = "
                   (vl-princ-to-string (getvar sysvar))
           )
         )
       )
     )

     (princ "ON ")
   )
 )

 (princ)
)

 

These days, I tend to use MGDDBG (or its Civil 3D counterpart) for things like this, but feel free to use what is most comfortable for you.

 

Cheers

Posted

Ahhh, brilliant.

 

Thanks so much for the help BlackBox.

 

I did test the code I posted above (for experimental purposes) and you were spot on, I got multiple alerts for each SYSVAR as they were altered. It also reported changes to every SYSVAR, rather than just the one I was trying to monitor.

 

I implemented your routine, and enabled it to alert me with a popup message each time DIMSCALE is changed. So hopefully it will just be a matter of time before I weed out the routine guilty.

 

The code I am using:

 

(vl-load-com)
  
 (defun c:svt ()
   (if *DIMSCALEReactor*
     (progn
       (vlr-remove *DIMSCALEReactor*)
       (setq *DIMSCALEReactor* nil)
       (setq DIMSCALE:Callback nil)
       (prompt "\nReactor stopped. ")
     )
     (progn
       (setq *DIMSCALEReactor*
              (vlr-sysvar-reactor
                ""
                '(
                  (:vlr-sysvarchanged . DIMSCALE:Callback)
                 )
              )
       )
       (defun DIMSCALE:Callback (rea var / varName)
         (if
           (and
             (wcmatch (setq varName (strcase (car var))) "DIMSCALE")
             (cdr var)
           )
            (alert
              (strcat "\n[App Event] : System Var Changed\t\t: " varName)
            )
         )
       )
       (prompt "\nReactor started. ")
     )
   )
   (princ)
 )
  

Thanks again, you've been a great help.

Posted

That is kind of you to say; I'm happy to help.

 

Cheers

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