找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 402|回复: 3

[每日一码] 显示实体数据

[复制链接]

已领礼包: 40个

财富等级: 招财进宝

发表于 2021-1-17 04:23:07 | 显示全部楼层 |阅读模式

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

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

×



The routine will let you select an entity and print the data (what is returned by 'entget') to a window.  From there you can select other enames, and their data will show up in the dialog box.  It is useful when looking for nested items, maybe in the extension dictionary of an entity (first 360 ename).  I still use it sometimes just to see what is happening with an entity.

The sub-routine does all the work, so you can use it also with 'nentsel', as it only cares about an ename.

I will add a second command 'ChaseData2' that appears to work with nested entities.  It will allow the use to select which item they want to chase.  I don't use it that often, so I hope it works well for others.

Make sure the dialog box file is in the search path.

The 'Definition' button will take you to the block table record of an insert.  If you are not looking at an insert, it will just stop the program.

You can either double click on the ename, or once it is selected hit the 'Ok' button to view that entity's data.

The 'Next Entity' button is used mostly for blocks to see the attributes, as they are the next entity or with old style polylines to see the vertex entity.

'Print Data' will just output the current data to the command line, but leave the dialog box open.

Hope others find it useful.  Hope I got all the sub-routines.

  1. (defun c:ChaseEntData (/ Sel)
  2.     (if (setq Sel (entsel))
  3.         (ChaseEntData (car Sel))
  4.     )
  5.     (princ)
  6. )

  7. (defun c:ChaseEntData2 ( / sel tList diaRtn )
  8.     (if (setq sel (nentsel))
  9.         (if (> (length sel) 2)
  10.             (if
  11.                 (setq diaRtn
  12.                     (SingleSelect
  13.                         (mapcar
  14.                             (function
  15.                                 (lambda ( a / data tType name )
  16.                                     (setq data (entget a))
  17.                                     (setq tType (cdr (assoc 0 data)))
  18.                                     (strcat
  19.                                         tType
  20.                                         (if (= tType "INSERT")
  21.                                             (progn
  22.                                                 (setq name (cdr (assoc 2 data)))
  23.                                                 (if (equal (logand (cdr (assoc 70 (entget (tblobjname "block" name)))) 4) 4)
  24.                                                     (strcat " ( XREF ) [ " name " ]")
  25.                                                     (strcat " [ " name " ]")
  26.                                                 )
  27.                                             )
  28.                                             ""
  29.                                         )
  30.                                     )
  31.                                 )
  32.                             )
  33.                             (setq tList (append (list (car sel)) (last sel)))
  34.                         )
  35.                         "Select entity to chase"
  36.                         nil
  37.                     )
  38.                 )
  39.                 (ChaseEntData (nth (car diaRtn) tList))
  40.             )
  41.             (ChaseEntData (car sel))
  42.         )
  43.     )
  44.     (princ)
  45. )
  46. ;-----------------------------------------
  47. (defun ChaseEntData (Ent / DiaRtn DataList data)
  48.    
  49.     (while
  50.         (and
  51.             Ent
  52.             (setq DiaRtn
  53.                 (SingleSelectWide
  54.                     (mapcar
  55.                         '(lambda (x / tempType)
  56.                             (if
  57.                                 (and
  58.                                     (equal (type (cdr x)) 'ENAME)
  59.                                     (setq tempType (cdr (assoc 0 (entget (cdr x)))))
  60.                                 )
  61.                                 (strcat
  62.                                     (vl-princ-to-string (car x))
  63.                                     "\t\t"
  64.                                     (vl-princ-to-string (cdr x))
  65.                                     "  [ "
  66.                                     tempType
  67.                                     " ]"
  68.                                 )
  69.                                 (strcat
  70.                                     (vl-princ-to-string (car x))
  71.                                     "\t\t"
  72.                                     (vl-princ-to-string (cdr x))
  73.                                 )
  74.                             )
  75.                         )
  76.                         (setq DataList (entget Ent '("*")))
  77.                     )
  78.                     "Select entity name to chase."
  79.                     nil
  80.                 )
  81.             )
  82.         )
  83.         (cond
  84.             ((equal (type DiaRtn) 'LIST)
  85.                 (if (not (equal (type (setq Ent (cdr (nth (car DiaRtn) DataList)))) 'ENAME))
  86.                     (setq Ent nil)
  87.                 )
  88.             )
  89.             ((equal (type DiaRtn) 'INT)
  90.                 (cond
  91.                     ((equal DiaRtn 2)
  92.                         (setq Ent (entnext ent))
  93.                     )
  94.                     ((equal DiaRtn 3)
  95.                         (pedata Ent)
  96.                     )
  97.                     ((equal DiaRtn 4)
  98.                         (setq Ent
  99.                             (if (= (cdr (assoc 0 (setq data (entget ent)))) "INSERT")
  100.                                 (tblobjname "block" (cdr (assoc 2 data)))
  101.                             )
  102.                         )
  103.                     )
  104.                 )
  105.             )
  106.         )
  107.     )
  108. )

  109. ;---------------------------------------------------------------------

  110. (defun SingleSelect (Listof Message Toggle / DiaLoad tmpStr tmpTog tmpList)

  111.         (setq DiaLoad (load_dialog "MyDialogs.dcl"))
  112.         (if (new_dialog "SingleSelect" DiaLOad)
  113.                 (progn
  114.                         (start_list "listbox" 3)
  115.                         (mapcar 'add_list Listof)
  116.                         (end_list)
  117.                         (if Message
  118.                         (set_tile "text1" Message)
  119.                         )
  120.                         (if (not Toggle)
  121.                                 (mode_tile "toggle1" 1)
  122.                         )
  123.                         (action_tile "listbox"
  124.                                 "(if (= $reason 4)
  125.                                         (progn
  126.                                                  (setq tmpStr (get_tile \"listbox\"))
  127.                                                  (if Toggle
  128.                                                         (setq tmpTog (get_tile \"toggle1\"))
  129.                                                  )
  130.                                                  (done_dialog 1)
  131.                                         )
  132.                                 )"
  133.                         )     
  134.                         (action_tile "accept"
  135.                                 "(progn
  136.                                         (setq tmpStr (get_tile \"listbox\"))
  137.                                         (if Toggle
  138.                                                 (setq tmpTog (get_tile \"toggle1\"))
  139.                                         )
  140.                                         (done_dialog 1)
  141.                                 )"
  142.                         )
  143.                         (action_tile "cancel" "(done_dialog 0)")
  144.                         (if (= (start_dialog) 1)
  145.                                 (progn
  146.                                 (setq tmpList (read (strcat "(" tmpStr ")")))
  147.                                 (if (= tmpTog "1")
  148.                                          (cons T tmpList)
  149.                                          tmpList
  150.                                 )
  151.                                 )
  152.                         )
  153.                 )
  154.         )
  155. )

  156. ;---------------------------------------------------------------------------------

  157. (defun SingleSelectWide (Listof Message Toggle / DiaLoad tmpStr tmpTog tmpList diaOpt )

  158.         (setq DiaLoad (load_dialog "MyDialogs.dcl"))
  159.         (if (new_dialog "SingleSelectWide" DiaLOad)
  160.                 (progn
  161.                         (start_list "listbox" 3)
  162.                         (mapcar 'add_list Listof)
  163.                         (end_list)
  164.                         (if Message
  165.                         (set_tile "text1" Message)
  166.                         )
  167.                         (if (not Toggle)
  168.                                 (mode_tile "toggle1" 1)
  169.                         )
  170.             (action_tile "entNext" "(done_dialog 2)")
  171.             (action_tile "print" "(done_dialog 3)")
  172.             (action_tile "blkDef" "(done_dialog 4)")
  173.                         (action_tile "listbox"
  174.                                 "(if (= $reason 4)
  175.                                         (progn
  176.                                                  (setq tmpStr (get_tile \"listbox\"))
  177.                                                  (if Toggle
  178.                                                         (setq tmpTog (get_tile \"toggle1\"))
  179.                                                  )
  180.                                                  (done_dialog 1)
  181.                                         )
  182.                                 )"
  183.                         )     
  184.                         (action_tile "accept"
  185.                                 "(progn
  186.                                         (setq tmpStr (get_tile \"listbox\"))
  187.                                         (if Toggle
  188.                                                 (setq tmpTog (get_tile \"toggle1\"))
  189.                                         )
  190.                                         (done_dialog 1)
  191.                                 )"
  192.                         )
  193.                         (action_tile "cancel" "(done_dialog 0)")
  194.             (setq diaOpt (start_dialog))
  195.             (setq temp diaOpt)
  196.                         (cond
  197.                 ((= diaOpt 1)
  198.                     (setq tmpList (read (strcat "(" tmpStr ")")))
  199.                     (if (= tmpTog "1")
  200.                          (cons T tmpList)
  201.                          tmpList
  202.                     )
  203.                                 )
  204.                 ((> diaOpt 1)
  205.                     diaOpt
  206.                 )
  207.                         )
  208.                 )
  209.         )
  210. )
  211. ;-------------------------------------------------------
  212. (defun PEData (EntData)
  213.    
  214.     (if (equal (type EntData) 'ENAME)
  215.         (setq EntData (entget EntData '("*")))
  216.     )
  217.     (foreach lst EntData
  218.         (if (equal (car lst) -3)
  219.             (progn
  220.                 (princ "\n(-3")
  221.                 (foreach i (cdr lst) (print i))
  222.                 (princ "\n)")
  223.             )
  224.             (print lst)
  225.         )
  226.     )
  227.     (princ)
  228. )


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

已领礼包: 3751个

财富等级: 富可敌国

发表于 2021-1-17 08:45:57 | 显示全部楼层
还差一个DCL文件

MyDialogs.zip

2.66 KB, 下载次数: 12, 下载积分: D豆 -1 , 活跃度 1

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

使用道具 举报

已领礼包: 2230个

财富等级: 金玉满堂

发表于 2021-1-17 10:31:25 | 显示全部楼层
做个对论坛有益的人。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2021-1-17 10:39:42 | 显示全部楼层
做个对论坛有益的人。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-5-14 00:30 , Processed in 0.403627 second(s), 38 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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