马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- (defun XD::Hatch:GetLoopEnts (ha / box dis e ents ge2d ge3d ges loops loops1 n ss tf tf1 x)
- (if (xdrx_object_isa ha "AcDbHatch")
- (progn
- (setq ents (xdrx_getpropertyvalue ha "AssocObjIds")) ; 如果是关联的直接返回曲线
- (if (not ents)
- (progn
- (setq ges (xdrx_getpropertyvalue ha "getloops" t) ; 获得所有的边LOOP几何实体
- ges (mapcar
- '(lambda (x)
- (if (= (xdge::type x) "kCompositeCrv2d")
- (list x (xdge::getpropertyvalue x "getcurvelist"))
- (if (= (type x) 'LIST)
- (cons (xdge::constructor "kCompositecrv2d" x) x)
- x
- )
- )
- )
- ges
- )
- ges (xd::list:flat ges)
- box (xdrx_entity_box ha)
- )
- (setq tf1 (XD::Doc:SafeZoom box)) ; 确保边界范围显示在屏幕内
- (if (setq ss (ssget "cp" box '((0 . "LINE,POLYLINE,LWPOLYLINE,SPLINE,ARC,CIRCLE,ELLIPSE")))) ; 构建CP曲线选择集
- (progn
- (setq loops (xdrx_pickset->ents ss))
- (foreach n ges
- (setq tf t
- loops1 loops
- )
- (while (and
- tf
- (setq e (car loops1))
- )
- (setq ge3d (xdge::constructor e)
- ge2d (xdge::entity:3d->2d ge3d)
- )
- (if (and
- (if (/= (xdge::type n) "kCompositeCrv2d")
- (xdge::getpropertyvalue n "isparallelto" ge2d)
- t
- )
- (equal (xdge::getpropertyvalue n "length")
- (xdge::getpropertyvalue ge2d "length") 1e-2
- )
- (equal (setq dis (xdge::getpropertyvalue n "distanceto"
- ge2d
- )
- )
- 0.0 1e-2
- )
- ) ; 判断是否平行、长度相同、距离=0
- (setq ents (cons e ents)
- tf nil
- )
- )
- (setq loops1 (cdr loops1))
- (xdge::free ge2d ge3d)
- )
- )
- (setq ents (reverse ents))
- )
- )
- (if tf1
- (xdrx_document_zoomprevious) ; 如果ZOOM,恢复原来的显示
- )
- (xdge::free ges)
- )
- )
- )
- )
- ents
- )
测试工具
- (defun c:tt ()
- (while (and
- (setq e (car (xdrx_entsel "\n点取填充<退出>:" '((0 . "HATCH")))))
- (setq ents (xd::hatch:getloopents e))
- )
- (progn
- (XD::Pickset:GripDisplay ents)
- )
- )
- (princ)
- )
|