马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
研究了几天几何库,试着写个教学,望高手指正
用XDGE几何库实现曲线打断(主要功能)的代码
一、单点打断
- (defun c:tt1()
- (if (and (setq e (xdrx_entsel "\n拾取要单点打断的曲线<退出>:" '((0 . "*LINE,ARC,CIRCLE,ELLIPSE"))))
- (setq ge1 (xdge::constructor (car e)))
- (setq ge2 (xdge::copy ge1))
- (setq intval (xdge::getpropertyvalue ge1 "getInterval"))
- )
- (progn
- (setq intval (car intval)
- bounds (xdge::getpropertyvalue intval "getBounds")
- lower (car bounds)
- upper (cadr bounds)
- param (xdge::getpropertyvalue ge1 "paramOf" (cadr e))
- intval1 (xdge::constructor "AcGeInterval" lower param)
- intval2 (xdge::constructor "AcGeInterval" param upper)
- )
- (if (xdge::setpropertyvalue ge1 "setInterval" intval1);;设置曲线1的起始、结束参数
- (xdge::entity:make ge1)
- )
- (if (xdge::setpropertyvalue ge2 "setInterval" intval2);;设置曲线2的起始、结束参数
- (xdge::entity:make ge2)
- )
- (xdrx_entity_delete (car e))
- (xdge::free)
- )
- )
- (princ)
- )
一、两点打断
- (defun c:tt2()
- (if (and (setq e (xdrx_entsel "\n拾取要两点打断的曲线<退出>:" '((0 . "*LINE,ARC,CIRCLE,ELLIPSE"))))
- (setq p1 (getpoint "\n第一点<退出>:"))
- (setq p2 (getpoint p1 "\n第二点<退出>:"))
- (setq ge1 (xdge::constructor (car e)))
- (setq ge2 (xdge::copy ge1)) ;;复制一个
- (setq intval (xdge::getpropertyvalue ge1 "getInterval"))
- (setq param1 (xdge::getpropertyvalue ge1 "paramOf" p1))
- (setq param2 (xdge::getpropertyvalue ge1 "paramOf" p2))
- )
- (progn
- (setq pa1 (min param1 param2)
- pa2 (max param1 param2)
- intval (car intval)
- bounds (xdge::getpropertyvalue intval "getBounds")
- lower (car bounds)
- upper (cadr bounds)
- intval1 (xdge::constructor "AcGeInterval" lower pa1)
- intval2 (xdge::constructor "AcGeInterval" pa2 upper)
- )
- (if (and (xdge::setpropertyvalue ge1 "setInterval" intval1);;设置曲线1的起始、结束参数
- (> (xdge::getpropertyvalue ge1 "Length") 0) ;;长度大于0生成
- )
- (xdge::entity:make ge1)
- )
- (if (and (xdge::setpropertyvalue ge2 "setInterval" intval2);;设置曲线2的起始、结束参数
- (> (xdge::getpropertyvalue ge2 "Length") 0);;长度大于0生成
- )
- (xdge::entity:make ge2)
- )
- (xdrx_entity_delete (car e))
- (xdge::free)
- )
- )
- (princ)
- )
两个程序的主要原理都是建立曲线几何模型,然后拷贝复制一个,然后通过设置两个GE曲线的起始、终止参数来实现打断的,主要的几何库打断函数用的是 (xdge::setpropertyvalue ge "setInterval" intval)
|