Jump to content

VLR-SysVar-Reactor Help


harrison-matt

Recommended Posts

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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")) 
     )
 )

Link to comment
Share on other sites

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")) 
)
)

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

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