乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 56|回复: 2

[编程交流] VBA - Title Block Attribute

[复制链接]

3

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 21:46:21 | 显示全部楼层 |阅读模式
Hello,                                  I had been asked if I could find a way to automate the creation of an Index for the Title Page for our projects, in as few steps as possible. the Index is simple, consisting of two Header elements (1) "Sheet No." and (2) "Drawing Title".                                  I have successfully been able to create the "Index" with the (1) column of the "Sheet No." using VBA into an Excel speadsheet then pasting it back into AutoCad. Where I am getting stuck is in capturing the "Drawing Title" that resides with in the Title Block of each drawing files as an attribute. I need automate this for each drawing in the project and do not want to use the Data Extraction.                                  Any help would be greatly appreciated and get me going in the right direction.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 22:45:09 | 显示全部楼层
Your welcome to edit this
         
       
  1. ; dwg index to a table; by Alan H NOV 2013(defun AH:dwgindex (/ doc objtable ss1 lay ans ans2 plotabs ss1 tag2 tag3 list1 list2 curlayout colwidth numcolumns numrows INC rowheight )(vl-load-com)(setq curlayout (getvar "ctab"))(if (= curlayout "Model")(progn(Alert "You need to be in a layout for this option")(exit)) ; end progn) ; end if model(setq doc (vla-get-activedocument (vlax-get-acad-object)))(setq curspace (vla-get-paperspace doc))(setq pt1 (vlax-3d-point (getpoint "\nPick point for top left hand of table:  "))) ; read values from title blocks(setq bname "DA1DRTXT")(setq tag2 "DRG_NO") ;attribute tag name(setq tag3 "WORKS_DESCRIPTION") ;attribute tag name(setq ss1 (ssget "x"  (list (cons 0 "INSERT") (cons 2 bname))))(if (= ss1 nil) ; for tomkinson jobs(progn (setq bname "COGG_TITLE")(setq ss1 (ssget "x"  (list (cons 0 "INSERT") (cons 2 bname))))))(setq INC (sslength ss1))  (repeat INC(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 (SETQ INC (- INC 1)) )) 'getattributes)         (if (= tag2 (strcase (vla-get-tagstring att)))            (progn            (setq ans (vla-get-textstring att))            (if (/= ans NIL)            (setq list1 (cons ans list1))            ) ; if             ); end progn          ) ; end if        (if (= tag3 (strcase (vla-get-tagstring att)))          (progn          (setq ans2 (vla-get-textstring att))          (if (/= ans2 NIL)              (setq list2 (cons ans2 list2))            ) ; end if           ) ; end progn     ) ; end if tag3     ) ; end foreach) ; end repeat(setvar 'ctab curlayout)(command "Zoom" "E")(command "regen")(reverse list1);(reverse list2); now do table (setq numrows (+ 2 (sslength ss1)))(setq numcolumns 2)(setq rowheight 0.2)(setq colwidth 150)(setq objtable (vla-addtable curspace pt1 numrows numcolumns rowheight colwidth))(vla-settext objtable 0 0 "DRAWING REGISTER")(vla-settext objtable 1 0 "DRAWING NUMBER") (vla-settext objtable 1 1 "DRAWING TITLE") (SETQ X 0)(SETQ Y 2)(REPEAT (sslength ss1)  (vla-settext objtable Y 0 (NTH X LIST1))  (vla-settext objtable Y 1 (NTH X LIST2))  (vla-setrowheight objtable y 7)  (SETQ X (+ X 1))  (SETQ Y (+ Y 1)))(vla-setcolumnwidth objtable 0 55)(vla-setcolumnwidth objtable 1 170)(command "_zoom" "e")); end AH defun(AH:dwgindex)(princ)
回复

使用道具 举报

3

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 23:13:12 | 显示全部楼层
Thanks BIGAL,
        I will modify and implement this into my code and process.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 14:36 , Processed in 0.445697 second(s), 58 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表