马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 a117034423 于 2021-2-3 08:34 编辑
- (defun c:xbtt ( / ss2)
- (setq ss2 (ssget '(
- (-4 . "<or")
- (-4 . "<AND")
- (0 . "LWPOLYLINE")
- (8 . "板轮廓线")
- (-4 . "AND>")
- (-4 . "or>")
- )
- ))
- (xbttt ss2)
- )
- (defun xbttt (ss0 / i tt1 form-txt form-pt ty1 n pt1)
- (defun form-txt (pt1 str1 clr /) ;创建文字函数
- (entmake (list
- '(0 . "TEXT")
- '(100 . "AcDbEntity")
- '(8 . "构件信息")
- '(100 . "AcDbText")
- '(7 . "tssd_rein")
- '(41 . 0.7)
- (cons 1 str1)
- (cons 10 pt1)
- (cons 11 pt1)
- (cons 40 80)
- (if clr
- (cons 62 clr)
- (cons 62 256)
- )
- '(72 . 4)
- ))
- )
- (defun form-pt (ent1 / ptmin ptmax ptzz mod0 xcc dxy) ;求矩形中心点
- (setq mod0 (vl-remove nil (mapcar '(lambda (x) (if (= (car x) 10) (cdr x))) (entget ent1)))
- ptmin (apply 'mapcar (cons 'min mod0))
- ptmax (apply 'mapcar (cons 'max mod0))
- dxy (mapcar '- ptmax ptmin)
- ptzz (mapcar '+ ptmax ptmin)
- ptzz (list (* (car ptzz) 0.5) (* (cadr ptzz) 0.5) 0.0)
- xcc (vlax-ldata-get (vlax-ename->vla-object ent1) "XB")
- xcc (subst (cons "长度" (rtos (max (car dxy) (cadr dxy)) 2 0)) (assoc "长度" xcc) xcc)
- xcc (subst (cons "宽度" (rtos (min (car dxy) (cadr dxy)) 2 0)) (assoc "宽度" xcc) xcc)
- xcc (subst (cons "体积" (rtos (* (vlax-curve-getArea (vlax-ename->vla-object ent1)) (cdr (assoc "厚" xcc)) 1e-9) 2 2)) (assoc "体积" xcc) xcc)
- xcc (subst (cons "重量" (rtos (* (atof (cdr (assoc "体积" xcc))) 2.5) 2 2)) (assoc "重量" xcc) xcc)
- xcc (vlax-ldata-put (vlax-ename->vla-object ent1) "XB" xcc))
- ptzz
- )
- (setq i 0)
- (repeat (sslength ss0)
- (setq ty1 (ssname ss0 i)
- pt1 (form-pt ty1)
- tt1 (append (vlax-ldata-get (vlax-ename->vla-object ty1) "NO") (vlax-ldata-get (vlax-ename->vla-object ty1) "XB"))
- n 0
- i (1+ i)
- )
- (repeat (length tt1)
- (form-txt (list (car pt1) (+ (cadr pt1) (* (length tt1) 50)) 0.0) (strcat (car (nth n tt1)) " : " (if (/= (type (cdr (nth n tt1))) (type "str"))
- (rtos (cdr (nth n tt1)) 2 0)
- (cdr (nth n tt1)))) 256)
- (setq pt1 (list (car pt1) (- (cadr pt1) 100) 0.0)
- n (1+ n)
- )
- )
- )
- (princ)
- )
|