Jump to content
harrison-matt

VLR-SysVar-Reactor Help

Recommended Posts

harrison-matt

All,

 

I am looking for a way to create a reactor that changes a system variable back to specific variable when it is changed by a User or AutoCAD.

 

Specifically i am talking about MLEADERSCALE, you might have noticed that if you have several styles and you switch between them your Mleaderscale resets to 1 or the specific scale set in the style. I set dimscale and mleaderscale the same and when that change happens mleaderscale ends up changing forcing me to reset the mleaderscale after each time the style is changed.

 

I want to see the feasibility of using VLR-SysVar-Reactor and :VLR-sysVarWillChange and :VLR-sysVarChanged. I having trouble understanding the right code involved with these reactions. My furthest experience with VLR is just VLR-Command-Reactor's.

 

 

objective:

When Mleaderscale changes, it is reset to the current value of dimscale.

 

Any help or nudge would be greatly appreciated,

 

Matt

Share this post


Link to post
Share on other sites
BlackBox

My two cents...

 

*IF* your intended goal is to change the value of a sysvar (assuming you set it correctly at open), then I would suggest going with the :vlr-sysVarChanged callback. If you're familiar with the syntax of vlr-command-reactor, then you should have no problems with the callback list items required for :vlr-sysVarChanged.

 

Put some code together, and test it. If you're still having trouble, or want to try something unique, post the code and let us know.

 

Hope this helps!

Share this post


Link to post
Share on other sites
lpseifert

my version doesn't have the sysvar Mleaderscale so this is completely untested

(vl-load-com)
(defun mlsreact ()
 (if (not mls_react)
   (setq  mls_react (vlr-sysvar-reactor nil '((:vlr-sysVarChanged . mls2ds)))) 
 ) 
) 
(mlsreact)

(defun mls2ds    (event parameter)
 (if (eq (car parameter) "MLEADERSCALE")
   (setvar "mleaderscale" (getvar "dimscale")) 
     )
 )

Share this post


Link to post
Share on other sites
BlackBox

As a wise man once said...

 

So much for teaching.

 

 

lol :P

Share this post


Link to post
Share on other sites
harrison-matt

I tested this and the program resulted in an error crashing my autocad when the event is provoked.

 

my version doesn't have the sysvar Mleaderscale so this is completely untested

(vl-load-com)
(defun mlsreact ()
(if (not mls_react)
(setq mls_react (vlr-sysvar-reactor nil '((:vlr-sysVarChanged . mls2ds)))) 
) 
) 
(mlsreact)

(defun mls2ds (event parameter)
(if (eq (car parameter) "MLEADERSCALE")
(setvar "mleaderscale" (getvar "dimscale")) 
)
)

Share this post


Link to post
Share on other sites
lpseifert

well I'll be dipped in sh**... hoped you learned something

Share this post


Link to post
Share on other sites
harrison-matt

 

Me too, I am working on my program now, if i get anywhere or have any questions stick around.

Share this post


Link to post
Share on other sites
BlackBox
well I'll be dipped in sh**... hoped you learned something

 

Me too, I am working on my program now, if i get anywhere or have any questions stick around.

 

 

Stay tuned.... same 'Bat-Channel', same 'Bat-Time'... :lol:

Share this post


Link to post
Share on other sites
alanjt

You are creating your own infinite loop by having a reactor that activates each time the MLEADERSCALE is changed and setting it to something else, thus activating the reactor within the reactor.

 

Try something like this:

 

(defun mls2ds (event parameter)
 (if (and (eq (car parameter) "MLEADERSCALE")
          (/= (getvar "MLEADERSCALE") (getvar "dimscale"))
     )
   (setvar "mleaderscale" (getvar "dimscale"))
 )
)

This way it will fire the second time around, but it will notice that the MLEADERSCALE and the DIMSCALE are equal and will not continue.

Share this post


Link to post
Share on other sites
harrison-matt

Thanks, now i get it!

Share this post


Link to post
Share on other sites
Lee Mac
my version doesn't have the sysvar Mleaderscale so this is completely untested

(vl-load-com)
(defun mlsreact ()
 (if (not mls_react)
   (setq  mls_react (vlr-sysvar-reactor nil '((:vlr-sysVarChanged . mls2ds)))) 
 ) 
) 
(mlsreact)

(defun mls2ds    (event parameter)
 (if (eq (car parameter) "MLEADERSCALE")
   (setvar "mleaderscale" (getvar "dimscale")) 
     )
 )

 

Be careful of recursive looping Larry...

 

The reactor will react to the callback etc...

 

EDIT: Alan got there first - shoulda read the thread first...

Share this post


Link to post
Share on other sites
lpseifert

Ya learn something new everyday... thanks to both

I guess I should have tested it with different sysvars. I might have found the problem prior to posting... oh well

Share this post


Link to post
Share on other sites
alanjt
Ya learn something new everyday... thanks to both

I guess I should have tested it with different sysvars. I might have found the problem prior to posting... oh well

Long ago, I had to crash AutoCAD three times before I realized what the problem was.

Share this post


Link to post
Share on other sites
Lee Mac

I've inadvertently done it too, don't worry :)

 

Usually happens with Object Reactors.. :S

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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