- 积分
- 13477
- 明经币
- 个
- 注册时间
- 2019-3-22
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 1028695446 于 2022-10-25 18:41 编辑
1、将面域转化成多段线,可以框选(批量转化)
2、支持面域中含有样条曲线(SPLINE)边界
3、支持3维空间中的面域
(defun C:REGX(/ ss_reg_PLANESURFACE ss_sp ss_lst ss_spx ss_next ss1 ss2 entmark ent_mark ent_mark0 ent_mark_spline spline_ctrl)
(princ "\n 提取面域和平面曲面边界(多段线)")
(setq spline_ctrl 10);;样条曲线转换成多段线的精度
(if (setq ss_reg_PLANESURFACE(ssget '((0 . "REGION,PLANESURFACE"))))
(progn
(setq ss_lst (ss-enlst ss_reg_PLANESURFACE))
(setq ent_mark0 (entlast))
(foreach x ss_lst
(setq ent_mark (entlast))
(command "XEDGES" (ssadd x) "")
(if (not (equal (entlast) ent_mark 0.01))
(progn
;;===================================================
(setq ss_next (MJ:EntNextAll_G ent_mark))
(command "SELECT" ss_next "" )
(setvar "peditaccept" 1)
(if (setq ss_sp (ssget "P" '((0 . "SPLINE"))))
(progn
(setq ent_mark_spline (entlast))
(command "_pedit" "M" ss_sp "" spline_ctrl "");;精度
(setq ss_spx (MJ:EntNextAll_G ent_mark))
(command "EXPLODE" ss_spx "")
)
)
;;===================================================
(setq ss_next (MJ:EntNextAll_G ent_mark))
(command "SELECT" ss_next "" )
(if(setq ss (ssget "P" '((0 . "*LINE,ARC,SPLINE")(-4 . "<not")(70 . 1)(-4 . "not>"))))
(progn
(setq entmark(entlast))
(setvar "peditaccept" 1)
(command "_pedit" (ssname ss 0) "J" ss "" "")
(setq ss1(MJ:EntNextAll_G entmark))
(setq ss(ssuni ss ss1))
(command "_pedit" "m" ss "" "join" "J" "E" "0.0005" "")
)
(princ"\n未选择对象,请重试")
)
;;===================================================连成多段线
)
)
)
(if (setq ss2(MJ:EntNextAll_G ent_mark0))
(progn
(command "SELECT" ss2 "" )
(sssetfirst ss2 ss2)
)
)
)
(princ "\n 请选择 region 或 PLANESURFACE")
)
(princ)
)
;;;======================选择集与对象名表互转
(defun ss-enlst (ss / enlst)
(cond
((= (type ss) 'PICKSET)
(vl-remove-if-not '(lambda (x) (= (type x) 'ENAME)) (mapcar 'cadr (ssnamex SS)))
)
((= (type ss) 'LIST)
(setq enlst (ssadd))
(last (mapcar '(lambda (x) (ssadd x enlst)) ss))
)
)
)
;;;======================函数取得en之后生成的所有图元的选择集
(defun MJ:EntNextAll_G (EN / LST)
(if EN
(while (setq EN (entnext EN))
(if (not (member (cdr (assoc 0 (entget EN)))
'("ATTRIB" "VERTEX" "SEQEND")
)
)
(setq LST (cons EN LST))
)
)
(ssget "_X")
)
(ss-enlst(reverse LST))
)
;;;======================选集相加
(defun ssuni (ss1 ss2 / i res)
(setq i 0)
(repeat (sslength ss2)
(ssadd (ssname ss2 i) ss1)
(setq i (1+ i))
)
(setq res ss1)
)
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
评分
-
查看全部评分
|