明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 550|回复: 5

[提问] Eentsel 选取对象问题

[复制链接]
发表于 2021-4-14 10:03 | 显示全部楼层 |阅读模式
请大师指正一下,希望实现选取对象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
  •   )
  • )
发表于 2021-4-14 12:32 | 显示全部楼层
本帖最后由 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 | 显示全部楼层
(defun c:tt (/ ss)
(while (= ss nil)
(OR (setq ss(ssget ":S" '((0 . "LWPOLYLINE"))))
  (princ "\n没选到"))
)
(princ "选到了")
(prin1)
)
 楼主| 发表于 2021-4-14 19:33 | 显示全部楼层
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
 楼主| 发表于 2021-4-14 19:34 | 显示全部楼层
菜卷鱼 发表于 2021-4-14 14:23
(defun c:tt (/ ss)
(while (= ss nil)
(OR (setq ss(ssget ":S" '((0 . "LWPOLYLINE"))))

貌似不可以用ssget的,会出错,只能用entsel
发表于 2021-4-15 09:02 | 显示全部楼层
程序前加(vl-load-com)
选择前加(setq name nil)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-19 09:47 , Processed in 0.346245 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表