ERROR AND MTEXT

ERROR AND MTEXT

etilley327KA
Advocate Advocate
955 Views
23 Replies
Message 1 of 24

ERROR AND MTEXT

etilley327KA
Advocate
Advocate

I really could use some help. I keep getting an error somewhere in my math functions, but I dont see it. Also, my mtext isnt working either. Im trying to add text with the variables. 

 
(defun c:XC (/ tmn tdp mtof mtoc mdis slope mdn apron pt1)
            (setq tmn (getreal "\nEnter SLOPE tolerance: "))
            (setq tdp
              (cond
                (XSTRCASE(getreal "\nEnter standard drop or <Enter for 0.67>: "))
                (0.67)
              )
            )
            (setq mtof (getreal "\nEnter TOF: "))
            (setq mtoc (getreal "\nEnter TOC: "))
            (setq mdis (getreal "\nEnter Distance: "))
              (setq slope (rtos (* (/ (- mtof tdp mtoc) mdis) 100) 2 0))
              (setq mdn (- mtof (+ mtoc (* (/ tmn 100) mdis)) 0.375))
              (setq apron (- mtof (+ 0.375 mdn)))
                (if (< slope tmn)
                  (progn
                    (alert "Too High")
                    (command "mtext" (setq pt1 (getpoint "\nSelect Point: ") ) pt1 slope apron mtof mtoc mdis tdp "")
                  )
                    (command "mtext" (setq pt1 (getpoint "\nSelect Point: ") ) pt1 (strcat slope "%") "")
                )
  (princ)
)
0 Likes
Accepted solutions (1)
956 Views
23 Replies
Replies (23)
Message 21 of 24

ВeekeeCZ
Consultant
Consultant

2 notes.

 

1) I would be careful with the debugger you are using. Even I don't know what values you enter, but in my opinion, there is no input that would bypass the syntax error in line 5. The screenshot from msg 5 does not make sense. VLIDE editor stops there with an error.

 

2) Post your final code - did you fix the syntax error in the COND function too?

 

Message 22 of 24

etilley327KA
Advocate
Advocate
(defun c:XC (/ tmn tdp mtof mtoc mdis slope mdn apron pt1)
            (setq tmn (getreal "\nEnter SLOPE tolerance: "))
            (setq tdp
              (cond
                ((getreal "\nEnter standard drop or <Enter for 0.67>: "))
                (0.67)
              )
            )
            (setq mtof (getreal "\nEnter TOF: "))
            (setq mtoc (getreal "\nEnter TOC: "))
            (setq mdis (getreal "\nEnter Distance: "))
              (setq slope (* (/ (- mtof tdp mtoc) mdis) 100))
              (setq mdn (- mtof (+ mtoc (* (/ tmn 100) mdis)) 0.375))
              (setq apron (- mtof (+ 0.375 mdn)))
                (if (> slope tmn)
                  (progn
                    (alert "Too High")
                    (command "mtext" (setq pt1 (getpoint "\nSelect Point: ") ) pt1
                             (strcat (rtos slope 2 0) "%"
                              "\\PApron " (rtos apron 2 2)
                              "\\PTOF " (rtos mtof 2 2)
                              "\\PTOC " (rtos mtoc 2 2)
                              "\\PDist " (rtos mdis 2 2)
                              "\\PDrop " (rtos tdp 2 2)) "")
                  )
                    (command "mtext" (setq pt1 (getpoint "\nSelect Point: ") ) pt1 (strcat (rtos slope 2 0) "%") "")
                )
  (princ)
)
 
Message 23 of 24

ВeekeeCZ
Consultant
Consultant

Approved.

0 Likes
Message 24 of 24

calderg1000
Mentor
Mentor

Regards @etilley327KA 

Here you have another option. To use Strcat requires converting numbers to text. But Mtext also accepts integer or real numbers as an argument.

 

(defun c:XC(/ tmn tdp mtof mtoc mdis slope mdn apron pt1)
  (setq tmn (getreal "\nEnter SLOPE tolerance: "))
  (initget "S D")
  (setq opc (getkword "\nEnter (Standard Drop=0.67/Drop Value?)[S/D] <S>: "))
  (if (/= opc "D")
    (setq tdp 0.67)
    (setq tdp (getreal "\nEnter Drop Value: "))
  )
  (setq mtof  (getreal "\nEnter TOF: ")
        mtoc  (getreal "\nEnter TOC: ")
        mdis  (getreal "\nEnter Distance: ")
        slope (* (/ (- mtof tdp mtoc) mdis) 100)
        mdn   (- mtof (+ mtoc (* (/ tmn 100) mdis)) 0.375)
        apron (- mtof (+ 0.375 mdn))
  )
  (if (< (fix slope) tmn)
    (progn
      (alert "Too High")
      (command "mtext"
               (setq pt1 (getpoint "\nSelect Point: "))
               pt1
               (strcat (rtos(fix slope)2 0) "%")
               apron
               mtof
               mtoc
               mdis
               tdp
               ""
      )
    )
    (command "mtext"
             (setq pt1 (getpoint "\nSelect Point: "))
             pt1
             (strcat (rtos slope 2 0) "%")
             ""
    )
  )
  (princ)
)

 

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes