明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3824|回复: 5

[分享]有關點選亮顯xref內物件的貼子

[复制链接]
发表于 2004-11-5 17:31 | 显示全部楼层 |阅读模式

有关点选亮显xref内物件的贴子

http://discussion.autodesk.com/thread.jspa?threadID=365179

评分

参与人数 1威望 +1 金钱 +5 贡献 +5 激情 +5 收起 理由
alin + 1 + 5 + 5 + 5 【精华】好程序

查看全部评分

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2004-11-5 19:42 | 显示全部楼层
顶一下
  1. ;;;BY LUCAS
  2. ;;; highlighted not support objects inside xref-----ployline=AcDb2dVertex ,AcDbAttribute
  3. ;;;
  4. ;;; Block Isolate
  5. ;;;
  6. ;;; Revised from original code:
  7. ;;; From: Jeff Mishler (jeff_m@cadvault.com)
  8. ;;; Subject: Re: Layiso and Blocks
  9. ;;; Newsgroups: autodesk.autocad.customization
  10. ;;; Date: 2004-08-24 15:09:03 PST
  11. (defun ISOBLKLAY (BLOCKREF / GET_LAY_LIST BLOCK BLOCKLAY)   ;; function to get layer list of block
  12.    (defun GET_LAY_LIST (BLK / LAY BLOCK)
  13.        (setq BLOCK
  14.        (vla-item (vla-get-blocks
  15.                  DOC
  16.              ) ;_ vla-get-blocks
  17.              (vla-get-name BLK)
  18.        ) ;_ vla-item
  19.        ) ;_ setq
  20.        (vlax-for ENT BLOCK
  21.            (setq LAY (vla-get-layer ENT))
  22.            (if (not (member LAY LAYLIST))
  23.   (setq LAYLIST (cons LAY LAYLIST))
  24.            ) ;_ if
  25.            (if (= (strcase "AcDbBlockreference")
  26.            (strcase (vla-get-objectname ENT))
  27.      ) ;_ =
  28.   (GET_LAY_LIST ENT)
  29.            ) ;_ if
  30.        ) ;_ vlax-for
  31.    ) ;_ defun
  32.    ;; select block to isolate
  33.    (and (setq BLOCK (vlax-ename->vla-object BLOCKREF))
  34.              (= (strcase "AcDbBlockreference")
  35.      (strcase (vla-get-objectname BLOCK))
  36.              ) ;_ =
  37.              ;; get list of layers in block
  38.              (GET_LAY_LIST BLOCK)
  39.    ) ;_ and
  40.    (setq LAY (cdr (assoc 8 (entget BLOCKREF))))
  41.    (if (not (member LAY LAYLIST))
  42.        (setq LAYLIST (cons LAY LAYLIST))
  43.    ) ;_ if
  44.    LAYLIST
  45. ) ;_defun(defun ERR_LAI (S)
  46.    (if
  47.        (not (member S '("console break" "function cancelled")))
  48.          (princ (strcat "\nError: " S))
  49.    )
  50.    (command "" "_.erase" SS_DEL "")
  51.    (if OLDERR
  52.        (setq *ERROR* OLDERR)
  53.    )
  54.    (if HOLDECHO
  55.        (setvar "cmdecho" HOLDECHO)
  56.    )
  57.    (princ)
  58. );;==========================
  59. (defun C:SSISOBLK (/
  60.          LAYERS
  61.          DBXDOC
  62.          SS
  63.          SSI
  64.          ENT1
  65.          LAYLIST
  66.          LAY
  67.          MSPACE
  68.          ENT
  69.          VOBJ
  70.          MATRIX
  71.          COPYOBJ
  72.          ENT1
  73.          ID
  74.          ENTDBX
  75.          SS_DEL
  76.          DOC
  77.        )   (vl-load-com)
  78.    (setq  DOC       (vla-get-activedocument (vlax-get-acad-object))
  79.   LAYERS (vla-get-layers DOC)
  80.   MSPACE (vla-get-modelspace DOC)
  81.    )
  82.    (vla-startundomark DOC) ;_ vla-startundomark
  83.    (setq  OLDERR  *ERROR*
  84.   *ERROR*  ERR_LAI
  85.    )
  86.    (setq HOLDECHO (getvar "cmdecho"))
  87.    (setvar "CMDECHO" 0)   (if (> (atoi (getvar "AcadVer")) 15)
  88.        (setq DBXDOC (vla-getinterfaceobject
  89.          (vlax-get-acad-object)
  90.          "ObjectDBX.AxDbDocument.16"
  91.      )
  92.        )
  93.        (setq DBXDOC (vla-getinterfaceobject
  94.          (vlax-get-acad-object)
  95.          "ObjectDBX.AxDbDocument"
  96.      )
  97.        )
  98.    )   ;;-------------Modify By LUCAS-------------
  99.    ;;The Selecting objects in normal, just like "Block Isolate.lsp"
  100.    ;;Select normal object,then "push enter" to Select object inside block
  101.    ;;didn't hit "enter" twice please
  102.    (setq SS (ssget))   (if (not SS)
  103.        (setq SS (ssadd))
  104.    )   (command "_.Select" SS)   ;;Select Objects inside Xref
  105.    (setq SS_DEL (ssadd))
  106.    (while
  107.        (progn
  108.            (setvar "ERRNO" 0)
  109.            (setq
  110.   ENT
  111.    (nentselp
  112.        "\nSelect Objects inside Xref/<Enter exit>: "
  113.    )
  114.            )
  115.            (if (/= 52 (getvar "ERRNO"))
  116.   t
  117.            )
  118.        )
  119.          (if ENT
  120.              (progn
  121.    (prompt
  122.        (strcat
  123.            "\nObject layer = "
  124.            (setq LAY (cdr (assoc 8 (entget (car ENT)))))
  125.        )
  126.    )   (if (not (member LAY LAYLIST))
  127.        (setq LAYLIST (cons LAY LAYLIST))
  128.    )   (setq COPYOBJ (vlax-ename->vla-object (car ENT)))   (cond
  129.        ((and
  130.              (> (length ENT) 2)
  131.              (cond
  132.     ((and
  133.          (setq
  134.              XREFOBJ (vlax-ename->vla-object
  135.                    (car (last ENT))
  136.                )
  137.          )
  138.          (vlax-property-available-p XREFOBJ "PATH")
  139.      )
  140.     )
  141.     ((and
  142.          (setq
  143.              XREFOBJ (vlax-ename->vla-object
  144.                    (cadr (last ENT))
  145.                )
  146.          )
  147.          (vlax-property-available-p XREFOBJ "PATH")
  148.      )
  149.     )
  150.              )
  151.          )         (vla-open DBXDOC (vla-get-path XREFOBJ))
  152.          (setq VOBJ (vlax-ename->vla-object (car ENT)))
  153.          (setq ID (vla-get-handle VOBJ))
  154.          (vlax-for ENT1 (vla-get-blocks DBXDOC)
  155.              (vlax-for  ENTDBX ENT1
  156.     (if (= ID (vla-get-handle ENTDBX))
  157.        (setq VOBJ ENTDBX)
  158.     )
  159.              )
  160.          )
  161.          (setq MATRIX (caddr ENT))
  162.          (setq
  163.              COPYOBJ
  164.                (car
  165.      (vlax-invoke
  166.          DBXDOC
  167.          'COPYOBJECTS
  168.          (list VOBJ)
  169.          (if
  170.              (or (= (getvar "TILEMODE") 1)
  171.        (> (getvar "CVPORT") 1)
  172.              )
  173.                (vla-get-modelspace DOC)
  174.                (vla-get-paperspace DOC)
  175.          )
  176.      )
  177.                )
  178.          )
  179.          (vla-transformby COPYOBJ (vlax-tmatrix MATRIX))
  180.          (ssadd (entlast) SS_DEL)
  181.        )
  182.    )   (vla-highlight COPYOBJ :vlax-true)
  183.              )
  184.          )
  185.    )
  186.    (command "")   (while (/= (sslength SS) 0)
  187.        (setq ENT1 (ssname SS 0))
  188.        (if  (= (cdr (assoc 0 (entget ENT1))) "INSERT")
  189.            (setq LAYLIST
  190.            (foreach ITEM (ISOBLKLAY (ssname SS 0))
  191.                (setq LAYLIST (cons ITEM LAYLIST))
  192.            )
  193.            )
  194.            (progn
  195.   (setq LAY (cdr (assoc 8 (entget (ssname SS 0)))))
  196.   (if (not (member LAY LAYLIST))
  197.      (setq LAYLIST (cons LAY LAYLIST))
  198.   ) ;_ if
  199.            )
  200.        )
  201.        (ssdel (ssname SS 0) SS)
  202.    )
  203.    ;; if layers found, isolate layers
  204.    (if LAYLIST
  205.        (progn
  206.            (vlax-for  LAY LAYERS
  207.   (if (not (member (vla-get-name LAY) LAYLIST))
  208.      ;; turn off layers not in block
  209.      (vla-put-layeron LAY :vlax-false)
  210.      ;; turn on layers in block
  211.      (vla-put-layeron LAY :vlax-true)
  212.   ) ;_ if
  213.            ) ;_ vlax-for
  214.        ) ;_progn
  215.    ) ;_ if   (command "_.erase" SS_DEL "")
  216.    (setq *ERROR* OLDERR)
  217.    (vla-endundomark DOC) ;_ vla-endundomark
  218.    (vlax-release-object DOC)
  219.    (vlax-release-object LAYERS)
  220.    (vlax-release-object MSPACE)
  221.    (vlax-release-object DBXDOC)
  222.    (setvar "cmdecho" HOLDECHO)
  223.    (princ)
  224. ) ;_ defun
发表于 2004-11-5 21:44 | 显示全部楼层
阿龙能否详细说说功能?



我试了一下,选中外部参照中任何一个实体,最后结果都是显示所有同一个外部参照的所有图层实体,和本图同名层实体,关闭其它图层,是这样么?
发表于 2004-11-8 10:47 | 显示全部楼层
对于XREF我很有兴趣的,但是为什么我不能运行? Command: SSISOBLK
Error: Automation Error. Problem in loading applicationUnknown command
"SSISOBLK". Press F1 for help.
 楼主| 发表于 2004-11-8 10:51 | 显示全部楼层
无痕:你没有看清楚贴子(有空再看一次)

Hello,
I've got two lisp routines that I've dreamed of combining. One routine is "Block Isolate.lsp" and the other is "Isolate_Xref_Layer.lsp".
Block Isolate is an awesome routine that will not only isolate the layer a block is inserted on, but also its nested layers. It also allows for a selection set.
Isolate_Xref_Layer will isolate a single layer in an xref (or elsewhere), but only one.
Would someone be willing to add the functionality of Isolate_Xref_Layer to Block Isolate? This dream routine would allow a selection set of objects that would also include xref layers.
A cool feature would be for the routine to do the same thing with xreffed blocks that Block Isolate does - that is to display all the nested layers of the block as well as its insertion layer.
I've tried using two books on lisp to understand Block Isolate so as to be able to write the routine; but I'm still a total rookie when it comes to lisp, etc.
I'd really appreciate some help. If I have to pay someone, so be it.
Thanks,
Jamie

那老外要求点选blk可孤立显示图层但又希望能单选孤立显示图层,所以程序分为2次选物件

 楼主| 发表于 2004-11-8 10:56 | 显示全部楼层
;;把这段改一下,可能你用r2005以下版本,所以ObjectDBX没有註册
;;------------------------------------------------------
(if (> (atoi (getvar "AcadVer")) 15)
(setq DBXDOC (vla-getinterfaceobject
(vlax-get-acad-object)
"ObjectDBX.AxDbDocument.16"
)
)
(setq DBXDOC (vla-getinterfaceobject
(vlax-get-acad-object)
"ObjectDBX.AxDbDocument"
)
)
) ;;-------------------------------------------------------
(if (> (atoi (getvar "AcadVer")) 15)
(setq DBXDOC (vla-getinterfaceobject
(vlax-get-acad-object)
"ObjectDBX.AxDbDocument.16"
)
)
(progn
(if (not (vl-registry-read
"HKEY_CLASSES_ROOT\\ObjectDBX.AxDbDocument\\CLSID"
)
)
(startapp "regsvr32.exe"
(strcat "/s \"" (findfile "axdb15.dll") "\"")
)
)
(setq DBXDOC (vla-getinterfaceobject
(vlax-get-acad-object)
"ObjectDBX.AxDbDocument"
)
)
)
)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-17 12:18 , Processed in 0.403904 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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