aksha Posted October 7, 2023 Posted October 7, 2023 (edited) I am a novice in VLISP programming. By using examples of code written by others, I craeted the following code. Here's what I want to achieve with it. When the value of CANNOSSCALE is changed, I want to trigger a change of DIMSCALE. And then Regen the drawing. In the code below, the line for regenerating the drawing is executed. But the line for changing DIMSCALE is not executed. It also does not produce any error. (vl-load-com) (if (null casr) (setq casr (vlr-sysvar-reactor nil '((:vlr-sysvarchanged . rgnlt)))) ) (defun rgnlt (casr cl) (cond ((= (car cl) "CANNOSCALE") (vl-cmdf "dimstyle" "_R" (strcat "SR" (vl-princ-to-string (fix (/ 1 (getvar "CANNOSCALEVALUE")))))) (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport) ) ) ) Edited October 7, 2023 by SLW210 Added Code Tags! Quote
mhupp Posted October 8, 2023 Posted October 8, 2023 I don't use reactors often. so I probably wouldn't give the best advice. but this website is pretty good in explain whats going on. https://www.afralisp.net/visual-lisp/tutorials/reactors-part-1.php Quote
rlx Posted October 8, 2023 Posted October 8, 2023 (edited) sadly I use dim / dimstyle pretty much never , my work is mostly about electrical schematics , loop diagrams and terminal lists that being said , command line is executed but vl-cmdf first checks if command is valid before doing something. Maybe replace vl-cmdf with command and you see what i mean. Anyways , think "dimstyle" should be "-dimstyle" to make use of command line version rather than dialog version. When I typed 'cannoscale' I got "1:1" , oh , this has something to do with scale , ok, I type 1:10 and see what happens... sure cannoscalevalue became 0.1 so , -dimstyle , _R is restore and the value your routine gave was SR10 (or SR1). I assume this kinda works like the text style command and style must be present in drawing? Hope his helps (and hello mhupp , saw you responded while I was typing ) gonna sleep now , it's 4 in the morning for me Edited October 8, 2023 by rlx Quote
BIGAL Posted October 8, 2023 Posted October 8, 2023 (edited) Also VLISP code not working (theswamp.org) http://www.theswamp.org/index.php?topic=58623.0 Edited October 8, 2023 by BIGAL Quote
Steven P Posted October 8, 2023 Posted October 8, 2023 (edited) What is the value of cl? No cl then (car cl) is nil I don't use reactors either, but when calling a function normally you'd need to specify the variables used so to use (defun rgnlt (casr cl) You'd normally call it with (rgnlt casr cl) Though not sure if this is different with reactors Edited October 8, 2023 by Steven P Quote
aksha Posted October 10, 2023 Author Posted October 10, 2023 @SLW210 Yes, I do use AutoCAD LT 2024 which is LISP enabled. Quote
aksha Posted October 10, 2023 Author Posted October 10, 2023 Thank you all for your inputs. Working solution is available here. https://www.theswamp.org/index.php?topic=58623.0 1 Quote
SLW210 Posted October 10, 2023 Posted October 10, 2023 6 hours ago, aksha said: @SLW210 Yes, I do use AutoCAD LT 2024 which is LISP enabled. It has limits, so it is something that needs clarified. Also, you show AutoCAD LT 2023 in your profile. 1 Quote
SLW210 Posted October 10, 2023 Posted October 10, 2023 4 hours ago, aksha said: Thank you all for your inputs. Working solution is available here. https://www.theswamp.org/index.php?topic=58623.0 Thanks for posting the solution! Quote
aksha Posted October 15, 2023 Author Posted October 15, 2023 Thank you all for your help. I have revised my code per the attached and it works as I intended. CannScl.lsp 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.