dilan Posted June 15, 2018 Share Posted June 15, 2018 (edited) Hello. In my program, I'm trying to assign a variable to a variable through a dialog: :edit_box{label=Text Height;key=get_txtheight;edit_width=5;value=2;} Then: (setq TextHeight (atoi (get_tile "get_txtheight"))) Then I want to assign a system variable TEXTSIZE the value of its local variable TextHeight: (setvar "TEXTSIZE" TextHeight) But there are problems, if I enter through a dialog a value for example 2.3, for a variable TEXTSIZE is always assigned integer 2. Or I get an error that setting the system variable TEXTSIZE rejected. I tried to use rtos, but nothing has changed ... Help please advice. Edited June 15, 2018 by dilan Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 15, 2018 Share Posted June 15, 2018 Try this probably the space in the name label=Text_Height or label=TextHeight Quote Link to comment Share on other sites More sharing options...
dilan Posted June 15, 2018 Author Share Posted June 15, 2018 Try this probably the space in the name label=Text_Height or label=TextHeight No. It did not help. Quote Link to comment Share on other sites More sharing options...
dilan Posted June 15, 2018 Author Share Posted June 15, 2018 I think the problem is atoi Quote Link to comment Share on other sites More sharing options...
dilan Posted June 15, 2018 Author Share Posted June 15, 2018 Does not help and atof Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted June 15, 2018 Share Posted June 15, 2018 I think you should look at your action_tile calls. (action_tile "accept" "(setq TextHeight (atoi (get_tile \"get_txtheight\"))) (done_dialog 1)") Quote Link to comment Share on other sites More sharing options...
rlx Posted June 15, 2018 Share Posted June 15, 2018 ' DIMZIN also affects real-to-string conversions performed by the AutoLISP rtos and angtos functions' or maybe just units setting? https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2019/ENU/AutoCAD-Core/files/GUID-A1860981-FE1C-4947-927B-7CD6B8CEF8EE-htm.html?st=DIMZIN The atof command should work though. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/atof-precision/td-p/836324 Quote Link to comment Share on other sites More sharing options...
dilan Posted June 15, 2018 Author Share Posted June 15, 2018 Nothing helps. If I enter a value of 2.6, then the variable is assigned to 3. If I enter 2.2 then 2. Numbers are always rounded up to integers. Quote Link to comment Share on other sites More sharing options...
rlx Posted June 15, 2018 Share Posted June 15, 2018 (edited) Nothing helps.If I enter a value of 2.6, then the variable is assigned to 3. If I enter 2.2 then 2. Numbers are always rounded up to integers. possible to post your code? Edited June 15, 2018 by rlx Quote Link to comment Share on other sites More sharing options...
rlx Posted June 15, 2018 Share Posted June 15, 2018 (edited) or maybe : http://www.cadtutor.net/forum/showthread.php?39358-Text-height-problem I think it is a problem with the Precision setting of your Units. Check it out. You probably have it set to "0". Change it to "0.0000" and see what happens. p.s. I assume you're not working with text styles that have a fixed height? Edited June 15, 2018 by rlx Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 15, 2018 Share Posted June 15, 2018 What happens if you manually enter the following at the command-line: (setvar 'textsize 2.5) Then: (getvar 'textsize) Quote Link to comment Share on other sites More sharing options...
dilan Posted June 15, 2018 Author Share Posted June 15, 2018 What happens if you manually enter the following at the command-line: (setvar 'textsize 2.5) Then: (getvar 'textsize) I successfully assign variable 2.5 Then I also successfully get the value of the variable 2.5 I guess the problem is in the code of the program itself. I will think ... look for this error Quote Link to comment Share on other sites More sharing options...
rlx Posted June 15, 2018 Share Posted June 15, 2018 I successfully assign variable 2.5Then I also successfully get the value of the variable 2.5 I guess the problem is in the code of the program itself. I will think ... look for this error somewhere along the line your value is incorrectly converted , either by rtos with wrong precision (rtos textheight 2 2) or wrong use of fix / atoi or you somehow recycle your value by not localizing it whatever. Hard to tell without seeing the code. Quote Link to comment Share on other sites More sharing options...
dilan Posted June 15, 2018 Author Share Posted June 15, 2018 I understood all the comments. I will correct the error myself. Thank you very much for your help and advice. When I get it, I'll write here what the error was. Quote Link to comment Share on other sites More sharing options...
dilan Posted June 16, 2018 Author Share Posted June 16, 2018 As it seems to me I understood the error .. (setq fp (vl-filename-mktemp "tempfile.dcl")) (setq fdcl (open fp "w")) (write-line " dcl_test : dialog {label = \"Coordinates\"; spacer; :spacer{height=0.5;} :column{label = \"Options \"; :edit_box {label = \"Rounding coordinates:\"; key = \"get_round\"; edit_width=5; value = \"3\";} :edit_box {label = \"Text Height:\"; key = \"get_txtheight\"; edit_width=5; value = \"2.5\";} :spacer{height=0.5;}} :spacer{height=0.5;} spacer; :button{key = \"acept\";label=\"Next\";is_default = true;height = 2;fixed_width = true;alignment = centered;} :button{key = \"cancel\";label=\"Exit\";height = 1;fixed_width = true;alignment = centered;} } " fdcl ) (close fdcl) (setq dcl_id (load_dialog fp)) (if (new_dialog "dcl_test" dcl_id) (progn (setq Round_xy (atoi (get_tile "get_round"))) (setq TextHeight_xy (atof (get_tile "get_txtheight"))) (action_tile "acept" "(done_dialog 1)") (action_tile "cancel" "(done_dialog 0)") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (unload_dialog dcl_id) (and fp (vl-file-delete fp)) ) (progn (alert "Unable to load the dialog!") (and fp (vl-file-delete fp))) ) In these lines of code my local variables Round_xy, TextHeight_xy get values from :edit_box - value =, if I enter another value in the dialog from :edit_box, then they are not assigned to my variables. And values are always assigned by default (:edit_box - value = ) And I do not understand how to fix it ... I understand that I'm starting with one problem and switching to another. I just try to figure it out myself. Sorry. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 16, 2018 Share Posted June 16, 2018 then they are not assigned to my variables. And values are always assigned by default (:edit_box - value = ) And I do not understand how to fix it ... Hi, Move them into the 'acpt' action. Quote Link to comment Share on other sites More sharing options...
dilan Posted June 16, 2018 Author Share Posted June 16, 2018 Hi, Move them into the 'acpt' action. Thank you so much. And earlier I was given this advice in this topic, but I thought the problem was different. (action_tile "acept" "(setq TextHeight_xy (atof (get_tile \"get_txtheight\"))) (setq Round_xy (atoi (get_tile \"get_round\"))) (done_dialog 1)") Now everything works as it should. Once again, thank you all. Quote Link to comment Share on other sites More sharing options...
dilan Posted June 16, 2018 Author Share Posted June 16, 2018 I think you should look at your action_tile calls. (action_tile "accept" "(setq TextHeight (atoi (get_tile \"get_txtheight\"))) (done_dialog 1)") Thank you. That helped. Quote Link to comment Share on other sites More sharing options...
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.