harrison-matt Posted September 20, 2010 Posted September 20, 2010 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 Quote
BlackBox Posted September 20, 2010 Posted September 20, 2010 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! Quote
lpseifert Posted September 20, 2010 Posted September 20, 2010 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")) ) ) Quote
BlackBox Posted September 20, 2010 Posted September 20, 2010 As a wise man once said... So much for teaching. lol Quote
harrison-matt Posted September 20, 2010 Author Posted September 20, 2010 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")) ) ) Quote
lpseifert Posted September 20, 2010 Posted September 20, 2010 well I'll be dipped in sh**... hoped you learned something Quote
harrison-matt Posted September 20, 2010 Author Posted September 20, 2010 Me too, I am working on my program now, if i get anywhere or have any questions stick around. Quote
BlackBox Posted September 20, 2010 Posted September 20, 2010 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'... Quote
alanjt Posted September 20, 2010 Posted September 20, 2010 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. Quote
Lee Mac Posted September 20, 2010 Posted September 20, 2010 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... Quote
lpseifert Posted September 20, 2010 Posted September 20, 2010 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 Quote
alanjt Posted September 20, 2010 Posted September 20, 2010 Ya learn something new everyday... thanks to bothI 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. Quote
Lee Mac Posted September 20, 2010 Posted September 20, 2010 I've inadvertently done it too, don't worry Usually happens with Object Reactors.. :S Quote
Recommended Posts
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.