dennylaw163 发表于 2021-4-14 10:03:49

Eentsel 选取对象问题

请大师指正一下,希望实现选取对象ractang是一个矩形,如果不是,继续选取。


[*](defun c:HV(/)
[*](setvar "cmdecho" 0)
[*]
[*](setq rectang (car(entsel"选择一个矩形")))
[*]
[*](setq re_content (entget rectang))
[*]
[*]
[*](setq Lst (mapcar 'cdr(vl-remove-if '(lambda (x) (/= (car x) 10)) re_content))
[*]
[*]    s1 (nth 0 Lst)
[*]
[*]    s2 (nth 1 Lst)
[*]
[*]    s3 (nth 2 Lst)
[*]
[*]    s4 (nth 3 Lst)
[*]
[*])
[*]
[*](command "ucs" "z" "0")
[*](command "plan" "")
[*](command "ucs" "")
[*](command "'-VIEW" "W" "v1" s2 s4)
[*](command "'-VIEW" "R" "v1")
[*]
[*]
[*](princ
[*])
[*])

wzg356 发表于 2021-4-14 12:32:55

本帖最后由 wzg356 于 2021-4-14 12:36 编辑

(while (/= name "AcDbrectang")
(and(setq en (car(entsel)))   
(= (cdr(assoc 0(entget en))) "LWPOLYLINE")   
(setq ob(vlax-ename->vla-object en))
(= (vlax-curve-getendparam ob) 4)
(setq a(vlax-curve-getDistAtParam ob 1))
(equal (vlax-curve-getArea ob)(* a (- (vlax-curve-getDistAtParam ob 2)a))1e-4)
(setq name "AcDbrectang")
)
)

菜卷鱼 发表于 2021-4-14 14:23:52

(defun c:tt (/ ss)
(while (= ss nil)
(OR (setq ss(ssget ":S" '((0 . "LWPOLYLINE"))))
(princ "\n没选到"))
)
(princ "选到了")
(prin1)
)

dennylaw163 发表于 2021-4-14 19:33:43

wzg356 发表于 2021-4-14 12:32
(while (/= name "AcDbrectang")
(and(setq en (car(entsel)))   
(= (cdr(assoc 0(entget en))) "LWPO ...

提示错误
error: bad argument type: consp nil

dennylaw163 发表于 2021-4-14 19:34:57

菜卷鱼 发表于 2021-4-14 14:23
(defun c:tt (/ ss)
(while (= ss nil)
(OR (setq ss(ssget ":S" '((0 . "LWPOLYLINE"))))


貌似不可以用ssget的,会出错,只能用entsel

wzg356 发表于 2021-4-15 09:02:35

程序前加(vl-load-com)
选择前加(setq name nil)
页: [1]
查看完整版本: Eentsel 选取对象问题