Guest Posted January 29, 2023 Share Posted January 29, 2023 (edited) Hi, I am using this code to do calculation in text or mtext for example, I have a text 6.00*8.00*2.70 + 6.00*8.00*(3.90-2.70)*1/3 + 1.70*3.00*2.38 and convert the text to the result 160.94 The problem is sometimes gives this error and I don't know why? ; error: no function definition: CAL Here is the code I use (defun c:cal2 (/ e) (setq e (car (entsel "\Select text or mtext: "))) (setq e (vlax-ename->vla-object e)) (vlax-property-available-p e 'textstring) (vla-put-textstring e (atof (rtos(cal (vla-get-textstring e)) 2 2))) (princ) ) Thanks Edited January 29, 2023 by prodromosm Quote Link to comment Share on other sites More sharing options...
Guest Posted January 29, 2023 Share Posted January 29, 2023 Can anyone tell me why I have this problem? Thanks Quote Link to comment Share on other sites More sharing options...
1958 Posted January 29, 2023 Share Posted January 29, 2023 (edited) Where is the "cal" function? (cal (vla-get-textstring e)) Edited January 29, 2023 by 1958 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted January 29, 2023 Share Posted January 29, 2023 If I run cal (autocad calculator) and do one simple calculation for example 3+2=5 then the lisp work without error. I don't kanow why this code stop work. In the begining befor 2 years this code works fine. Any options? Thanks Quote Link to comment Share on other sites More sharing options...
Tsuky Posted January 29, 2023 Share Posted January 29, 2023 See Prerequisites You must use (arxload "geomcal") before use (cal) Quote Link to comment Share on other sites More sharing options...
Guest Posted January 29, 2023 Share Posted January 29, 2023 Thanks Tsuky. I add this line and I think is working. I will test it more. Thanks (defun c:cal2 (/ e) (setq e (car (entsel "\Select text or mtext: "))) (setq e (vlax-ename->vla-object e)) (vlax-property-available-p e 'textstring) (arxload "geomcal") (vla-put-textstring e (atof (rtos(cal (vla-get-textstring e)) 2 2))) (princ) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 29, 2023 Share Posted January 29, 2023 Pretty sure there is a formula lisp, you enter formula and it works it out rather than CAL. Quote Link to comment Share on other sites More sharing options...
Guest Posted January 30, 2023 Share Posted January 30, 2023 Hi BIGAL. The only code I have is the code I post. Thanks Quote Link to comment Share on other sites More sharing options...
robierzo Posted January 30, 2023 Share Posted January 30, 2023 You must load the application using the expression (arxload "geomcal") Quote Link to comment Share on other sites More sharing options...
robierzo Posted January 30, 2023 Share Posted January 30, 2023 (edited) Sorry, I already saw that it was also recommended by Tsuky Edited January 30, 2023 by robierzo Quote Link to comment Share on other sites More sharing options...
Tharwat Posted January 30, 2023 Share Posted January 30, 2023 15 hours ago, prodromosm said: (vla-put-textstring e (atof (rtos(cal (vla-get-textstring e)) 2 2))) Copy and paste does not work most of the time without understanding the procedure of codes at least, so here is the missing part of your codes. (c:cal (vla-get-textstring e)) ;; note the c: before the cal command name Quote Link to comment Share on other sites More sharing options...
Steven P Posted January 30, 2023 Share Posted January 30, 2023 (edited) 1 hour ago, Tharwat said: Copy and paste does not work most of the time without understanding the procedure of codes at least, so here is the missing part of your codes. (c:cal (vla-get-textstring e)) ;; note the c: before the cal command name It works both ways for me, with a 'c:' and without it, AutoDesk help shows it both ways. Edited January 30, 2023 by Steven P 1 Quote Link to comment Share on other sites More sharing options...
Steven P Posted January 30, 2023 Share Posted January 30, 2023 So this routine is fixed in this instance but it doesn't explain why it worked sometimes and not sometimes. I might take a guess that you use some other calculations and if you haven't used one before in that session then 'geomcal' isn't loaded yet. "; error: no function definition: CAL" tells us that the function 'CAL' hasn't been loaded into memory for that drawing.. if you get a similar error in the future it means even if you have it saved in a file somewhere it still needs loading for the LISP to use it. Quote Link to comment Share on other sites More sharing options...
Guest Posted January 30, 2023 Share Posted January 30, 2023 Hi Steven P. I explain that cal command is Autocad cal command. I have no extra cal command to load. When i add this line (arxload "geomcal") The problem solved. I will add and Tharwat suggestion (vla-put-textstring e (atof (rtos(c:cal (vla-get-textstring e)) 2 2))) Thanks Quote Link to comment Share on other sites More sharing options...
Steven P Posted January 30, 2023 Share Posted January 30, 2023 1 hour ago, prodromosm said: Hi Steven P. I explain that cal command is Autocad cal command. I have no extra cal command to load. When i add this line (arxload "geomcal") .... OK.... so don't load the command with arxload.... 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.