嗨,塔瓦,
你的代码运行平稳,但这并不完全是我想要的。
我画的所有圆圈都在不同的图层上
此外,所有圆都(或应该)位于LWD多段线端点上(因此目前我不需要起点)。
如果这是真的,则必须将圆层名称写入列表。
但您的While循环将1个多段线端点与所有圆的中心点进行比较。
因此,如果假设集合中有77个圆,其中76个与循环中当前LWPOLYLINE端点的端点不匹配。
但是,它们确实与其他多段线端点匹配。
我想要实现的是,如果任何LWPOLYLINE端点与任何圆中心点匹配,则将圆图层名称写入列表
如果不是,则x数量的圆不位于LWD多段线端点上(CAD绘图员在修改过程中可能会移动一些圆),例程应终止并发出警报。
我对您的代码进行了一些修改,以显示我想要的:
- (defun c:Test ( / int sel ent lst )
- ;; Tharwat - Date: 11.Sep.2017 ;;
-
- (setq ss2_list nil)
- (setq wtg_id2_lst nil)
- (if
- (and
- (or
- (setq int -1 sel (ssget "_X" (list '(0 . "CIRCLE") (cons 410 (getvar 'CTAB)))))
- (alert "Couldn't find any circle in this drawing <!>")
- )
- (progn
- (while (setq ent (ssname sel (setq int (1+ int))))
- (setq ss2_list (cons (list ent (cdr (assoc 10 (entget ent)))) ss2_list))
- )
- ss2_list
- )
-
- (princ "\nSelect LWpolylines to change circles reside on their end points to MatchLayer :")
- (setq int -1 sel (ssget '((0 . "LWPOLYLINE"))))
- )
- (while (setq ent (ssname sel (setq int (1+ int))))
- (vl-some '(lambda (p)
- (cond ((equal (vlax-curve-getendpoint ent) (cadr p) 1e-4)
- (setq wtg_id2_lst (cons (cdr (assoc 8 (entget (car p)))) wtg_id2_lst))
- )
- ((/= (vlax-curve-getendpoint ent) (cadr p) 1e-4)
-
- ; All circles are (or should be) on endpoints of LWPOLYLINES
- ; So If any circle is not on any LWPOLYLINE endpoint then break the routine with an alert
- )
- )
- )
- ss2_list)
- )
- )
- (princ)
- )
- (vl-load-com)
|