- 积分
- 1135
- 明经币
- 个
- 注册时间
- 2010-8-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2013-11-2 12:18:54
|
显示全部楼层
本帖最后由 NJZX05 于 2013-11-2 12:39 编辑
;;第一过程,分别得到两边对象
(setq n 0 e1 nil YLst nil RLst nil)
(repeat (sslength ss)
(setq e2 (ssname ss n))
(if (= (cdr (assoc 62 (entget e1))) 1) (setq RLst (append RLst E1)));;得到红色组
(if (= (cdr (assoc 62 (entget e1))) 2) (setq RLst (append YLst E1)));;得到黄色组
);;repeat
;;第二过程,得到a1-a6;b1-b6
(setq PLstS nil)
(foreach YItem Ylst
(setq PLst nil)
(foreach RItem RLst
(setq PLst (append PLst (list (inters (cdr (assoc 10 (entget YItem))) (cdr (assoc 11 (entget YItem))) (cdr (assoc 10 (entget RItem))) (cdr (assoc 11 (entget RItem)))))))
)
(setq PLst (vl-sort PLst '(lambda (P1 P2) (< (cadr P1) (cadr P2)))));;按Y坐标排序
(setq PLsts (append PLsts (list PLst)))
)
;;第三过程,得到P1-P6
(setq PLst (mapcar '(LAMBDA (P1 P2) (LIST (/ (+ (CAR P1) (CAR P2)) 2) (/ (+ (CADR P1) (CADR P2)) 2) (/ (+ (CADDR P1) (CADDR P2)) 2))) (car PLsts) (cadr PLsts)))
;;第四过程,依次用P1-P6画线
(setq PS nil)
(while PLst
(cond
(PS (setq PE (car PLst) PLst (cdr PLst)) (command)
(command "LINE" (command PS) (command PE))
(setq PS nil)
)
(T (setq PS (car PLst) PLst (cdr PLst))
)
)
)
;;这里用了可能的各种循环,你慢慢看吧,我想你要的肯定在里面了
;;第四过程还可以这样写
;(setq PS nil Index -1)
;(repeat (length PLst)
; (setq Index (1+ Index))
; (cond
; (PS (setq PE (nth Inxex PLst)) (command)
; (command "LINE" (command PS) (command PE))
; (setq PS nil)
; )
; (T (setq PS (nth Inxex PLst))
; )
; )
;;如果想要连接画线,不间断,那么就这样写
;(setq PS nil)
;(while (setq PE (car PLst))
; (setq PLst (cdr PLst))
; (cond
; (PS (command)
; (command "LINE" (command PS) (command PE))
; (setq PS PE)
; )
; (T (setq PS PE))
; )
;)
|
|