我结合了一些代码,为您提供了一些其他的尝试:
- (defun c:test (/ ss i n text1 total volts amps)
- (initget 1 "208 480")
- (setq volts (getkword "\nEnter Voltage < 208 / 480 > : "))
- (if (= volts "208")
- (setq volts 360)
- (setq volts 831)
- )
- (setq ss (ssget '((0 . "TEXT")))
- i 0
- total 0
- n (sslength ss)
- )
- (if ss
- (while (< i n)
- (setq text1 (cdr (assoc 1 (entget (ssname ss i)))))
- (setq total (+ total (atof text1)))
- (setq i (1+ i))
- )
- )
- (princ (strcat "\nTOTAL WATTS = " (rtos total 2 0)))
- (while (not (setq watts (car (entsel "\nUpdate TOTAL DEMAND WATTS: ")))))
- (setq watts (entget watts))
- (if (eq (cdr (assoc 0 watts)) "TEXT")
- (entmod (setq watts (subst (cons 1 (rtos total 2 0)) (assoc 1 watts) watts)))
- (progn
- (princ "\nWrong Selection - Not Text!!")
- (exit)
- )
- )
- (princ (strcat "\nTOTAL AMPS = " (rtos (/ total volts) 2 1)))
- (while (not (setq amps (car (entsel "\nUpdate TOTAL DEMAND AMPS: ")))))
- (setq amps (entget amps))
- (if (eq (cdr (assoc 0 amps)) "TEXT")
- (entmod (setq amps (subst (cons 1 (rtos (/ total volts) 2 1)) (assoc 1 amps) amps)))
- (progn
- (princ "\nWrong Selection - Not Text!!")
- (exit)
- )
- )
- (princ)
- )
|