马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 newer 于 2016-11-30 00:24 编辑
需要的函数 XD::POLYLINE:IsCircArc 见:http://bbs.xdcad.net/thread-706316-1-1.html
[sell=5](defun c:XDTB_POLY<->CircArc ( / cr crvlst e ge info len ret ss tf x)
(defun _initget ()
(xdrx_prompt "\n当前模式:" (if (= 0 #poly_mode)
"圆、弧转多段线"
"多段线转圆、弧"
)
)
(xdrx_initssget info "PL BE")
)
(defun _process1 (ss / cr ge i x)
(setq i 0)
(mapcar
'(lambda (x)
(setq cr (xdge::constructor x))
(setq ge (xdge::constructor "kCompositeCrv3d" cr))
(xdge::entity:make ge)
(xdrx_entity_setpropertiesfrom (entlast) x)
(xdrx_object_swapid (entlast) x)
(xdrx_entity_delete (entlast))
(setq i (1+ i))
(xdge::free ge)
)
(xdrx_pickset->ents ss)
)
(xdrx_prompt "\n成功转换了" i "个圆、弧到多段线.")
)
(defun _process2 (ss / i info x)
(setq i 0)
(mapcar
'(lambda (x)
(if (setq info (xd::polyline:iscircarc x))
(progn
(setq i (1+ i))
(apply (if (= 2 (length info)) 'xdrx_circle_make 'xdrx_arc_make) info)
(xdrx_entity_setpropertiesfrom (entlast) x)
(xdrx_object_swapid (entlast) x)
(xdrx_entity_delete (entlast))
)
)
)
(xdrx_pickset->ents ss)
)
(xdrx_prompt "\n成功转换了" i "条多段线到圆、弧.")
)
(defun _process (ss)
(if (= #poly_mode 0)
(_process1 ss)
(_process2 ss)
)
)
(xdrx_begin)
(if (not #poly_mode)
(setq #poly_mode 0)
)
(setq info (strcat "\n选取要转换的" (if (= #poly_mode 0)
"圆、弧"
"多段线"
) "实体[圆弧(BE)/多段线(PL)]<退出>:"
)
)
(setq tf t)
(while (and
tf
(_initget)
(setq ss (xdrx_ssget (if (= #poly_mode 0)
'((0 . "CIRCLE,ARC"))
'((0 . "*POLYLINE"))
)
)
)
)
(cond
((= (type ss) 'PICKSET)
(setq tf nil)
(_process ss)
)
((= ss "BE")
(setq #poly_mode 0)
)
((= ss "PL")
(setq #poly_mode 1)
)
(t
(setq tf nil)
)
)
)
(xdrx_end)
(princ)
)
[/sell] |