Jump to content

; error: bad function: +


AbrAutoCADabra

Recommended Posts

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 by AbrAutoCADabra
Link to comment
Share on other sites

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)".

Link to comment
Share on other sites

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)".

 

Animation5.gif.c9f83e5ae6133d8c13149591acd62b95.gif

 

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

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

15 minutes ago, Kajanthan said:

 

Animation5.gif.c9f83e5ae6133d8c13149591acd62b95.gif

 

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!

Link to comment
Share on other sites

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.....

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...