martinle 发表于 2022-7-5 17:56:11

地区

你好,早上好!
我试图通过在一个封闭区域中“点击”来创建一个对象选择。通常,这是一条多段线。
如果封闭区域由多个物体包围,则应检索哪个物体以进行选择。
这可能吗?
lg。马丁

Tharwat 发表于 2022-7-5 18:00:52

你好
 
选择位于闭合多段线中的对象后,您会做什么?

martinle 发表于 2022-7-5 18:04:23

你好Tharwat!
 
我试着做到以下几点:
 
创建不同的命令组。
然后:
 
1) 通过单击“内部点”创建图案填充。
生产2)Scharffur
3) 注意到内部点击点
笔记
4) 单击点的边界对象。
此固定对象已属于某个组。
 
5) 现在,添加了该组创建的属于选定对象的图案填充
 
 
lg。马丁

Tharwat 发表于 2022-7-5 18:07:43

抱歉,这还不够清楚,但要填充区域,必须非常简单,可以使用第一个拾取点作为所需填充的基点来生成该区域。
 
无论如何,这里有一些代码来选择任何闭合对象中的对象:
 

(defun c:test (/ p e o l i d w)
(if (setq e (entlast)
            p (getpoint "\nPick a point in a closed Polyline :")
            )
(progn
   (command "_.-boundary" "_non" p "")
   (if (and (not (= e (setq o (entlast))))
            (eq (cdr (assoc 0 (entget o))) "LWPOLYLINE")
            )
   (progn
       (setq l (vlax-curve-getdistatparam o (vlax-curve-getendparam o))
             i (/ l 250)
             d i
             )
   (repeat 250
       (setq w (cons (vlax-curve-getpointatdist o d) w)
             d (+ d i)
             )
       )
       (entdel o)
       (sssetfirst nil (ssget "_WP" w))
       )
   )
   )
)
(princ)
)

martinle 发表于 2022-7-5 18:10:47

你好Tharwat!
 
不幸的是,我无法处理代码。
我试着在一个封闭的区域中点击一下,创建阴影,然后创建一个组
分配。
该组已经有库存。限定图案填充的对象属于此组。
 
 
lg。马丁

Tharwat 发表于 2022-7-5 18:14:48

嗨,Martin,
 
因此,在该闭合区域中选择对象后,您想将其分组吗?

martinle 发表于 2022-7-5 18:15:41

你好Tharwat!
构成分界的物体属于一个组
我想在这个对象组中添加图案填充
lg。马丁

marko_ribar 发表于 2022-7-5 18:20:10

试试这个:
 
(defun c:test ( / selareabypt p )

(defun selareabypt ( pt / el ss lw i e )
   (vl-load-com)
   (setq el (entlast))
   (setq ss (ssget "_A"
                   (list '(-4 . "<or")
                           '(-4 . "<and")
                           '(0 . "LWPOLYLINE") '(38 . 0.0) '(210 0.0 0.0 1.0)
                           '(-4 . "and>")
                           '(-4 . "<and")
                           '(0 . "POLYLINE") '(10 0.0 0.0 0.0) '(210 0.0 0.0 1.0)
                           '(-4 . "and>")
                           '(-4 . "<and")
                           '(0 . "LINE") '(-4 . "*,*,=") '(10 0.0 0.0 0.0) '(-4 . "*,*,=") '(11 0.0 0.0 0.0)
                           '(-4 . "and>")
                           '(-4 . "<and")
                           '(0 . "ARC") '(-4 . "*,*,=") '(10 0.0 0.0 0.0) '(210 0.0 0.0 1.0)
                           '(-4 . "and>")
                           '(-4 . "<and")
                           '(0 . "CIRCLE") '(-4 . "*,*,=") '(10 0.0 0.0 0.0) '(210 0.0 0.0 1.0)
                           '(-4 . "and>")
                         '(-4 . "or>")
                         (cons 410 (if (= 1 (getvar 'cvport)) (getvar 'ctab) "Model"))
                   )
            )
   )
   (repeat (setq i (sslength ss))
   (setq e (ssname ss (setq i (1- i))))
   (if (eq (cdr (assoc 0 (entget e))) "POLYLINE")
       (if (/= (last (assoc 10 (entget (entnext e)))) 0.0)
         (ssdel e ss)
       )
   )
   )
   (command "_.SELECT" ss "")
   (command "_.-BOUNDARY" "_A" "_B" "_N" "_P" "" "_I" "_Y" "_O" "_P" "" "_non" pt "")
   (setq sss (ssadd))
   (if (not (eq el (entlast)))
   (progn
       (setq lw el)
       (while (setq lw (entnext lw))
         (repeat (setq i (sslength ss))
         (setq e (ssname ss (setq i (1- i))))
         (if (vlax-invoke (vlax-ename->vla-object lw) 'intersectwith (vlax-ename->vla-object e) acextendnone)
             (ssadd e sss)
         )
         )
         (entdel lw)
       )
   )
   )
   sss
)

(setq p (getpoint "\nPick or specify point inside area : "))
(sssetfirst nil (selareabypt p))
(princ)
)
HTH,M.R。

martinle 发表于 2022-7-5 18:24:19

你好,Marko
 
几乎正确。
 
如果点位于多段线内,则仅选择它们。
如果点以多个对象为边界,则应查询应选择哪个对象。
 
lg。马丁

marko_ribar 发表于 2022-7-5 18:26:57

Martin,试试这个应该能满足你需要的模型-它现在应该适用于WCS中放置的所有2d曲线类型。。。
 
(defun c:test ( / *error* selareabypt p i sss )

(defun *error* ( msg )
   (if msg
   (prompt msg)
   )
   (princ)
)

(defun selareabypt ( pt / el ss lw i e )
   (vl-load-com)
   (setq el (entlast))
   (setq ss (ssget "_A"
                   (list '(-4 . "<or")
                           '(-4 . "<and")
                           '(0 . "LWPOLYLINE") '(38 . 0.0) '(210 0.0 0.0 1.0)
                           '(-4 . "and>")
                           '(-4 . "<and")
                           '(0 . "POLYLINE") '(10 0.0 0.0 0.0) '(210 0.0 0.0 1.0)
                           '(-4 . "and>")
                           '(-4 . "<and")
                           '(0 . "LINE") '(-4 . "*,*,=") '(10 0.0 0.0 0.0) '(-4 . "*,*,=") '(11 0.0 0.0 0.0)
                           '(-4 . "and>")
                           '(-4 . "<and")
                           '(0 . "ARC") '(-4 . "*,*,=") '(10 0.0 0.0 0.0) '(210 0.0 0.0 1.0)
                           '(-4 . "and>")
                           '(-4 . "<and")
                           '(0 . "CIRCLE") '(-4 . "*,*,=") '(10 0.0 0.0 0.0) '(210 0.0 0.0 1.0)
                           '(-4 . "and>")
                         '(-4 . "or>")
                         (cons 410 (if (= 1 (getvar 'cvport)) (getvar 'ctab) "Model"))
                   )
            )
   )
   (repeat (setq i (sslength ss))
   (setq e (ssname ss (setq i (1- i))))
   (if (eq (cdr (assoc 0 (entget e))) "POLYLINE")
       (if (/= (last (assoc 10 (entget (entnext e)))) 0.0)
         (ssdel e ss)
       )
   )
   )
   (command "_.SELECT" ss "")
   (command "_.-BOUNDARY" "_A" "_B" "_N" "_P" "" "_I" "_Y" "_O" "_P" "" "_non" pt "")
   (setq sss (ssadd))
   (if (not (eq el (entlast)))
   (progn
       (setq lw el)
       (while (setq lw (entnext lw))
         (repeat (setq i (sslength ss))
         (setq e (ssname ss (setq i (1- i))))
         (if (vlax-invoke (vlax-ename->vla-object lw) 'intersectwith (vlax-ename->vla-object e) acextendnone)
             (ssadd e sss)
         )
         )
         (entdel lw)
       )
   )
   )
   sss
)

(setq p (getpoint "\nPick or specify point inside area : "))
(if (eq (sslength (setq sss (selareabypt p))) 1)
   (sssetfirst nil sss)
   (progn
   (prompt "\nENTER FOR NEXT ENTITY...ESC TO KEEP CURRENT SELECTION AND TERMINATE ROUTINE...")
   (textscr)
   (repeat (setq i (sslength sss))
       (sssetfirst nil (ssadd (ssname sss (setq i (1- i)))))
       (while (progn (setq gr (grread nil)) (if (or (equal gr '(2 13)) (equal gr '(2 32))) (setq gr nil) t)))
   )
   )
)
(*error* nil)
)
M.R。
页: [1] 2
查看完整版本: 地区