明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: l_peng

[求助]请教如何用lisp方法获得没属性定义的块内部实体定义

  [复制链接]
 楼主| 发表于 2003-9-18 10:07:00 | 显示全部楼层
刚有个地方我说得不对,用(nentsel)返回的拷贝后的块中同一位置的实体名字是一样的。换句话说,“这8的图块中的实体与图块原始定义的实体是不同的”,我的这个说法可能不对,是不是只有炸开图块才表现为各有不同的实体?
  图我想不必给你,因为是任意直线和任意图块,我觉得你在ACAD中随便画的跟我的应该一样的。
发表于 2003-9-18 10:24:00 | 显示全部楼层
我要图只是想看看你复制的8个图块怎么个不同法。
现在看来是你对块定义和块引用的概念不清楚。
其实这八个INSERT对象都是对你原先定义的块的引用,炸开后就不是对块的引用了,而是成了独立的对象,当然不同INSERT对象炸开成的对象就不同了。

你试试这样,你重新定义一个块,最好跟原来的块的差别大一些。然后还用那个名字,就是将原来定义的块覆盖掉,你看看结果。
发表于 2003-9-18 12:48:00 | 显示全部楼层
;;VxGetBlockInters - Returns all intersection points between a block and an obj...
;;
;; -- Function VxGetBlockInters
;; Returns all intersection points between a Block and an object.
;; Copyright:
;;   ?001-2002 MENZI ENGINEERING GmbH, Switzerland
;; Arguments [Typ]:
;;   Blk = Block object [VLA-OBJECT]
;;   Obj = Object [VLA-OBJECT]
;;   Mde = Intersection mode [INT]
;;         Constants:
;;         - acExtendNone           Does not extend either object.
;;         - acExtendThisEntity     Extends the Fst object.
;;         - acExtendOtherEntity    Extends the Nxt object.
;;         - acExtendBoth           Extends both objects.
;; Return [Typ]:
;;   > list of points '((1.0 1.0 0.0)... [LIST]
;;   > Nil if no intersection found
;; Notes:
;;   None
;;
(defun VxGetBlockInters (Blk Obj Mde / ObjNme PntLst TmpVal)
(foreach memb (vlax-invoke Blk "Explode")
  (setq ObjNme (vla-get-ObjectName memb))
  (cond
   ((or
     (not (vlax-method-applicable-p memb 'IntersectWith))
     (and
      (eq ObjNme "AcDbHatch")
      (eq (strcase (vla-get-PatternName memb)) "SOLID")
     )
     (eq ObjNme "AcDb3dSolid")
    )
   )
   ((eq ObjNme "AcDbBlockReference")
    (if (setq TmpVal (VxGetBlockInters memb Obj Mde))
     (setq PntLst (append PntLst TmpVal))
    )
   )
   (T
    (if (setq TmpVal (VxGetInters memb Obj Mde))
     (setq PntLst (append PntLst TmpVal))
    )
   )
  )
  (vla-Delete memb)
)
PntLst
)


;;VxGetInters - Returns all intersection points between two objects
;;
;; -- Function VxGetInters
;; Returns all intersection points between two objects.
;; Copyright:
;;   ?000 MENZI ENGINEERING GmbH, Switzerland
;; Arguments [Typ]:
;;   Fst = First object [VLA-OBJECT]
;;   Nxt = Second object [VLA-OBJECT]
;;   Mde = Intersection mode [INT]
;;         Constants:
;;         - acExtendNone           Does not extend either object.
;;         - acExtendThisEntity     Extends the Fst object.
;;         - acExtendOtherEntity    Extends the Nxt object.
;;         - acExtendBoth           Extends both objects.
;; Return [Typ]:
;;   > list of points '((1.0 1.0 0.0)... [LIST]
;;   > Nil if no intersection found
;; Notes:
;;   None
;;
(defun VxGetInters (Fst Nxt Mde / IntLst PntLst)
(setq IntLst (vlax-invoke Fst "IntersectWith" Nxt Mde))
(cond
  (IntLst
   (repeat (/ (length IntLst) 3)
    (setq PntLst (cons
                  (list
                   (car IntLst)
                   (cadr IntLst)
                   (caddr IntLst)
                  )
                  PntLst
                 )
          IntLst (cdddr IntLst)
    )
   )
   (reverse PntLst)
  )
  (T nil)
)
)
 楼主| 发表于 2003-9-18 14:33:00 | 显示全部楼层
感谢你们,我试一试。
  原有的概念问题已经搞清,多谢版主。在图块炸开前不可能获得炸开后生成的实体名。我自己也另想出个办法,等写完程序贴上来,再交流。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-10-2 16:15 , Processed in 0.165161 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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