马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 newer 于 2016-6-11 15:39 编辑
最小二乘圆拟合函数见 xd::pnts:fitcircle
[sell=2]- (defun c:XDTB_JX2ARC ( / cen d ean g num pts r san ss temp x)
- (if (and
- (xdrx_prompt "\n选取要转圆弧的折线<退出>:" t)
- (setq ss (ssget '((0 . "*polyline"))))
- )
- (progn
- (setq num 0)
- (mapcar
- '(lambda (x)
- (xdrx_polyline_convertfrom x)
- (setq pts (xdrx_getpropertyvalue x "vertices"))
- (if (and
- (xdrx_polyline_isonlylines x)
- (> (length pts) 2)
- )
- (progn
- (setq d (xd::pnts:fitcircle pts))
- (if d
- (progn
- (setq cen (car d)
- r (cadr d)
- g (xdge::constructor "kCircArc3d" (car d) '
- (0 0 1.0) (cadr d)
- )
- )
- (if (not (xdrx_curve_isclosed x))
- (progn
- (setq san (angle cen (car pts))
- ean (angle cen (last pts))
- )
- (if (XD::Pnts:isClockWise pts)
- (setq temp san
- san ean
- ean temp
- )
- )
- (xdge::setpropertyvalue g "setangles" san ean)
- )
- )
- (xdge::entity:make g)
- (xdrx_object_swapid x (entlast))
- (xdrx_entity_delete (entlast))
- (setq num (1+ num))
- (xdge::free g)
- )
- )
- )
- )
- )
- (xdrx_pickset->ents ss)
- )
- (xdrx_prompt "\n选取了" (sslength ss) "个折线,转换成功了" num
- "个到圆弧."
- )
- )
- )
- (princ)
- )
[/sell]
|