problem:
I have code that adds metric to english feet and inches units. it works when the entity is just numbers.
example -
12'-6" will result in
12'-6" (3810mm) <- good
however if there is text in entity with the numbers its puts the metric at the end
example -
12'-6" dia circle will result in
12'-6" dia circle (3810mm) <- not good
and if there is a fraction in there...
example -
12'-6 1/2" dia circle results in
Select object: ; error: divide by zero <- :realmad:
goal:
what im after is no matter where in the string 12'-6 1/2" is, i want it to display the metric equivalent right next to it.
so if the string said "this is a 12'-6 1/2" dia circle"
i would like it to say "this is a 12'-6 1/2" (3823mm) dia circle"
for the life of me i just cant figure this out and hope someone can guide me in the right direction.
thanks
code:
please excuse the messy formating.
(DEFUN C:test (/)
(DEFUN FTDEC (ASTR / BUF RES C R1)
(SETQ BUF "" RES 0.0)
(WHILE (> (STRLEN ASTR) 0)
(SETQ C (SUBSTR ASTR 1 1) ASTR (SUBSTR ASTR 2))
(COND
((= C "'")
(SETQ RES (* (ATOF BUF) 12.0) BUF "" ASTR (SUBSTR ASTR 2))
)
((= C "/")
(SETQ R1 (ATOF BUF) BUF "")
)
((= C " ")
(SETQ RES (+ RES (ATOF BUF)) BUF "")
)
((/= C (CHR 34))
(SETQ BUF (STRCAT BUF C))
)
)
)
(IF R1
(+ RES (/ R1 (ATOF BUF)))
(+ RES (ATOF BUF))
)
);end while
;
(SETVAR "CMDECHO" 0)
(SETQ DSCL (GETVAR "DIMSCALE"))
(SETQ ENT1 (ENTSEL))
(SETQ ENT2 (ENTGET (CAR ENT1)))
(SETQ ANG1 (ATOF (ANGTOS (CDR (ASSOC 50 ENT2)))))
(SETQ NUM4 (CDR (ASSOC 1 ENT2)))
(IF (WCMATCH NUM4 "%%*")
(SETQ NUM4 (SUBSTR NUM4 4))
)
(setq Mort (CDR (ASSOC 0 ENT2)))
(SETQ NUM5 (FTDEC NUM4))
(IF (= NUM4 nil) (SETQ NUM4 0))
(SETQ P1 (* num5 25.4))
(IF (= MORT "TEXT")
(SETQ P4 (STRCAT (cdr (assoc 1 ent2))" (" (RTOS P1 2 0) "mm)"))
);END IF
(IF (= ANG1 0) (SETQ SPC (STRCAT "@0,-" (RTOS (* 0.2212 DSCL) 2))))
(IF (= ANG1 90) (SETQ SPC (STRCAT "@" (RTOS (* 0.2212 DSCL) 2) ",0")))
(IF (= ANG1 180) (SETQ SPC (STRCAT "@0," (RTOS (* 0.2212 DSCL) 2))))
(IF (= ANG1 270) (SETQ SPC (STRCAT "@-" (RTOS (* 0.2212 DSCL) 2) ",0")))
(SETVAR "CMDECHO" 1)
(SETQ ent2 (SUBST (CONS 1 P4) (ASSOC 1 ent2) Ent2))
(ENTMOD Ent2)
(PRINC)
)