有调试用文件否?

- (defun c:CS ()
- (vl-load-com)
- (setq modelspace
- (vla-get-Modelspace
- (vla-get-activeDocument (vlax-get-acad-object))
- )
- )
- (setq ent (ssname (ssget) 0)
- n (vlax-curve-getendParam ent)
- )
- ;; 如果是矩形
- (if (= n 4)
- ;; 计算长宽
- (progn ; 加入 progn
- (setq di (vlax-curve-getDistAtParam ent 1)
- dj (- (vlax-curve-getDistAtParam ent 2) di)
- text (strcat "L= " (rtos di 2 0) " B= " (rtos dj 2 0))
-
- ;; 计算插入点
- p1 (vlax-curve-getstartpoint ent)
- p3 (vlax-curve-getPointAtParam ent 2)
- x1 (car p1)
- y1 (cadr p1)
- x3 (car p3)
- y3 (cadr p3)
- x0 (-
- (/ (+ x1 x3) 2)
- (* (abs (- x1 x3)) 0.3)
- )
- y0 (/ (+ y1 y3) 2)
- )
- ;; 插入文字
- (if (setq insertpt (list x0 y0 0))
- (if (setq height (/ (min di dj) 15))
- (vla-addtext
- modelspace
- text
- (vlax-3D-point insertpt)
- height
- )
- )
- )
- )
- ;; 如果不是矩形
- ;;计算周长和面积
- (progn ; 加入 progn
- (setq SL (vlax-curve-getDistAtParam ent (vlax-curve-getendParam ent))
- SS (vlax-curve-getarea ent)
- text (strcat "SL= "
- (rtos (/ SL 1000) 2 2)
- "M SS= "
- (rtos (/ SS 1000000) 2 1)
- "M2"
- )
-
- ;; 计算插入点
- p1 (vlax-curve-getstartpoint ent)
- p3 (vlax-curve-getPointAtParam ent 2)
- x1 (car p1)
- y1 (cadr p1)
- x3 (car p3)
- y3 (cadr p3)
- x0 (-
- (/ (+ x1 x3) 2)
- (* (abs (- x1 x3)) 0.3)
- )
- y0 (/ (+ y1 y3) 2)
- )
- ;; 插入文字
- (if (setq insertpt (list x0 y0 0))
- (if (setq height (/ SL 50))
- (vla-addtext
- modelspace
- text
- (vlax-3D-point insertpt)
- height
- )
- )
- )
- )
- )
- )
|