找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 604|回复: 0

[曲线] (XD::Hatch:GetLoopEnts)从填充实体获取关联的或不关联的边界曲线

[复制链接]

已领礼包: 51个

财富等级: 招财进宝

发表于 2017-11-30 23:42:42 | 显示全部楼层 |阅读模式
函数发布
函数名称: XD::Hatch:GetLoopEnts
调用格式: (XD::Hatch:GetLoopEnts ha)
参数说明: ha ---- 填充实体名
返回值: 表 or nil
函数简介: 从填充实体获取关联的或不关联的边界曲线
函数来源: 原创
函数作者: lispboy
适用版本: XDRX API 
最后更新时间: 2017-11-30
备注: -
演示图片: -

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
  1. (defun XD::Hatch:GetLoopEnts (ha / box dis e ents ge2d ge3d ges loops loops1 n ss tf tf1 x)
  2.   (if (xdrx_object_isa ha "AcDbHatch")
  3.     (progn
  4.       (setq ents (xdrx_getpropertyvalue ha "AssocObjIds")) ; 如果是关联的直接返回曲线
  5.       (if (not ents)
  6.         (progn
  7.           (setq ges (xdrx_getpropertyvalue ha "getloops" t) ; 获得所有的边LOOP几何实体
  8.                 ges (mapcar
  9.                       '(lambda (x)
  10.                          (if (= (xdge::type x) "kCompositeCrv2d")
  11.                            (list x (xdge::getpropertyvalue x "getcurvelist"))
  12.                            (if (= (type x) 'LIST)
  13.                              (cons (xdge::constructor "kCompositecrv2d" x) x)
  14.                              x
  15.                            )
  16.                          )
  17.                        )
  18.                       ges
  19.                     )
  20.                 ges (xd::list:flat ges)
  21.                 box (xdrx_entity_box ha)
  22.           )
  23.           (setq tf1 (XD::Doc:SafeZoom box)) ; 确保边界范围显示在屏幕内
  24.           (if (setq ss (ssget "cp" box '((0 . "LINE,POLYLINE,LWPOLYLINE,SPLINE,ARC,CIRCLE,ELLIPSE")))) ; 构建CP曲线选择集
  25.             (progn
  26.               (setq loops (xdrx_pickset->ents ss))
  27.               (foreach n ges
  28.                 (setq tf t
  29.                       loops1 loops
  30.                 )
  31.                 (while (and
  32.                          tf
  33.                          (setq e (car loops1))
  34.                        )
  35.                   (setq ge3d (xdge::constructor e)
  36.                         ge2d (xdge::entity:3d->2d ge3d)
  37.                   )
  38.                   (if (and
  39.                         (if (/= (xdge::type n) "kCompositeCrv2d")
  40.                           (xdge::getpropertyvalue n "isparallelto" ge2d)
  41.                           t
  42.                         )
  43.                         (equal (xdge::getpropertyvalue n "length")
  44.                                (xdge::getpropertyvalue ge2d "length") 1e-2
  45.                         )
  46.                         (equal (setq dis (xdge::getpropertyvalue n "distanceto"
  47.                                                                  ge2d
  48.                                          )
  49.                                )
  50.                                0.0 1e-2
  51.                         )
  52.                       )                       ; 判断是否平行、长度相同、距离=0
  53.                     (setq ents (cons e ents)
  54.                           tf nil
  55.                     )
  56.                   )
  57.                   (setq loops1 (cdr loops1))
  58.                   (xdge::free ge2d ge3d)
  59.                 )
  60.               )
  61.               (setq ents (reverse ents))
  62.             )
  63.           )
  64.           (if tf1
  65.             (xdrx_document_zoomprevious) ; 如果ZOOM,恢复原来的显示
  66.           )
  67.           (xdge::free ges)
  68.         )
  69.       )
  70.     )
  71.   )
  72.   ents
  73. )


测试工具

获取填充边界.gif

  1. (defun c:tt ()
  2.   (while (and
  3.         (setq e (car (xdrx_entsel "\n点取填充<退出>:" '((0 . "HATCH")))))
  4.         (setq ents (xd::hatch:getloopents e))
  5.       )
  6.     (progn
  7.       (XD::Pickset:GripDisplay ents)
  8.     )
  9.   )
  10.   (princ)
  11. )


论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-3-29 21:27 , Processed in 0.364106 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表