求帮助修改小程序,感激!
本帖最后由 lxb9721 于 2019-3-21 16:23 编辑(defun C:EE ( / #g1 &kw &ss1 ent x)
(if (and
(setq ent (entsel "\n请选择封闭的多段线"))
(setq ent (car ent));图元
(setq #g1 (entget ent));属性
(= (cdr (assoc 0 #g1)) "LWPOLYLINE");分析是多段线
(= (cdr (assoc 70 #g1)) 1);判断是封闭
(setq &ss1 (mapcar 'cdr (vl-remove-if '(lambda (X) (/= 10 (car x))) #g1)));多段线上的点
)
(progn
(if (setq &kw (ssget "wp" &ss1))
;框选择 包含在框内的及和框相交的被选择;如果要窗选【cp】修改为【wp】即可
(setq &kw (ssadd ent &kw))
(progn
(setq &kw (ssadd) &kw (ssadd ent &kw))
)
)
(command "erase" "all" "r" &kw "")
)
)
(princ)
);
;根据删除后框内数据,计算最大值和最小值,平均值。
file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msohtml1/01/clip_image002.gif
本帖最后由 1291500406 于 2019-3-24 00:41 编辑
lxb9721 发表于 2019-3-22 10:19
(defun C:bb(/ lss en enlist)(setvar "cmdecho" 0)(setq en (car (entsel"\n必强提示:选择多段线\n")))
(if en(command "pedit" "M" en "" "C" ""))(setq enlist (entget en))(setq lss (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) enlist)))
(Setq bbsssetfirst (ssget "WP" lss '((0 . "TEXT")(1 . "~*[~`--9]*"))) )(sssetfirst nil bbsssetfirst)(bbaverage_max_min))
(defun bbaverage_max_min()(setq ss (ssget '((0 . "TEXT")))i -1 j 0 m 0)
(setq lst(mapcar '(lambda (x) (distof (cdr (assoc 1 (entget x)))))
(mapcar 'cadr (cdr (reverse (ssnamex ss)))))lst(vl-sort lst '>)bbmax (last lst)bbmin (car lst))
(while (setq s1 (ssname ss (setq i (1+ i))))(setq z (cdr (assoc 1 (entget s1))))
(if (setq z (distof z))(progn(setq j (1+ j)m (+ m z)))))
(princ "\n平均值 = ")(princ (/ m j 1.0))(princ "\n最大值 = ")(princ bbmin )(princ "\n最小值 = ")(princ bbmax )(princ))
最大最小值有点问题 1291500406 发表于 2019-3-23 23:26
(defun C:bb(/ lss en enlist)(setvar "cmdecho" 0)(setq en (car (entsel"\n必强提示:选择多段线\n")))
...
参数类型错误: numberp: nil lxb9721 发表于 2019-3-25 13:15
参数类型错误: numberp: nil
我的CAD02007测试正常
页:
[1]