AbrAutoCADabra Posted December 21, 2023 Posted December 21, 2023 (edited) Hello, I have added some more stuff (without changing too much) to one of my old codes that worked properly and now the new one gives me "; error: bad function: +", I have tried to figure out why this is happening without success. Can someone help me figure out what is causing the issue? I have uploaded both. Thanks in advance! Elevationpoint_New.lsp Elevationpoint_Old.lsp Edited December 21, 2023 by AbrAutoCADabra Quote
Kajanthan Posted December 25, 2023 Posted December 25, 2023 You forgot to add these lines to your new lisp. (defun LM:roundm (n m) (* m (fix ((if (minusp n) - +) (/ n (float m)) 0.5))) ) Quote
AbrAutoCADabra Posted December 27, 2023 Author Posted December 27, 2023 I did, it didn't change a thing it's just for the rounding. Quote
Steven P Posted December 27, 2023 Posted December 27, 2023 So how far through the routine does it go before the error occurs? 1 Quote
BIGAL Posted December 28, 2023 Posted December 28, 2023 Run in vlide etc can see where error occurs. 1 Quote
AbrAutoCADabra Posted December 28, 2023 Author Posted December 28, 2023 Hello again, this is from the command line in AutoCAD: Command: ELEVATIONPOINT Select the first elevation text (h1): Select object: Selected h1 elevation: 2.910000 Select the second elevation text (h2): Select object: Selected h2 elevation: 2.940000 Specify the start point of the line (h1): Specify the x-end point of the line (hX): Specify the end point of the line (h2): h1-elevation: 2.910000 h2-elevation: 2.940000 dX: 3.995743 d: 10.000000; error: bad function: + The error occurs as soon as I select "the end point of the line (h2)". Quote
Kajanthan Posted December 28, 2023 Posted December 28, 2023 1 hour ago, AbrAutoCADabra said: Hello again, this is from the command line in AutoCAD: Command: ELEVATIONPOINT Select the first elevation text (h1): Select object: Selected h1 elevation: 2.910000 Select the second elevation text (h2): Select object: Selected h2 elevation: 2.940000 Specify the start point of the line (h1): Specify the x-end point of the line (hX): Specify the end point of the line (h2): h1-elevation: 2.910000 h2-elevation: 2.940000 dX: 3.995743 d: 10.000000; error: bad function: + The error occurs as soon as I select "the end point of the line (h2)". This work after add these lines (defun LM:roundm (n m) (* m (fix ((if (minusp n) - +) (/ n (float m)) 0.5))) ) Elevationpoint_New 2.lsp 1 1 Quote
AbrAutoCADabra Posted December 28, 2023 Author Posted December 28, 2023 15 minutes ago, Kajanthan said: This work after add these lines (defun LM:roundm (n m) (* m (fix ((if (minusp n) - +) (/ n (float m)) 0.5))) ) Elevationpoint_New 2.lsp 4.05 kB · 0 downloads Hello, yes after running VLIDE I got directed to that part as well I think it had something to do where it was written in the code? (I had it in the beginning). But kudos to you for solving it! Quote
Steven P Posted December 28, 2023 Posted December 28, 2023 Just as a guide, I think Kajanthan has it, look through the code to see where it stops and then to the next point where it should tell you something and in that is where the problem is: (princ (strcat "\nd: " (rtos d 2 6))) ;;IT TELLS YOU FOR EXAMPLE 10.0000 ; Calculate hX elevation using the corrected formula (setq hX-elevation (+ h1-elevation (* (- h2-elevation h1-elevation) (/ dX d)) 0.0)) ; Round the elevation to two decimal places using the LM:roundm function (setq hX-elevation (LM:roundm hX-elevation 0.01)) ; Display the result in the command line (prompt (strcat "\nElevation of hX: " (rtos hX-elevation 2 6))) ; You can adjust the number of decimal places as needed ;;IT DOESN'T GET TO THIS PROMPT. ERROR IS IN THIS PART Should be easier to spot the problem when you identify where it is. 'Bad Function' means you are asking it to do something and it doesn't know what to do, something after a ( bracket..... 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.