乐筑天下

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

[编程交流] VBA AutoCAD命令行变量

[复制链接]

18

主题

118

帖子

101

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
89
发表于 2022-7-6 22:14:07 | 显示全部楼层
是的,这是真的,每当程序找到块“标题块”时,您可以获得属性并根据上述AttributeList(0)进行修改。TextString=“EXCEL行或单元格值”,或AttributeList(1)所需的其他属性。Textsring=“EXCEL ROW COLUMN”等。
修改重复属性时,您可以根据需要在两个位置上通过上述步骤为图形编号(仅为重复属性之一)指定值,因为您将为两个不同的块属性AttributeList(XX)指定相同的excel行或列内容。Textsring=“图纸编号的EXCEL行列”,属性列表(YY)。Textsring=“图纸编号第二位置的EXCEL行列”,与“问题”属性相同。
相反,有一种方法可以使用选择集选择特定的块,但由于内部有大量的块
回复

使用道具 举报

2

主题

19

帖子

17

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 22:19:39 | 显示全部楼层
i'm trying to run the code and it comes up with the error:
         
        user defined type not defined on line "TypeOf oEnt Is AcadBlockReference"
         
         
回复

使用道具 举报

18

主题

118

帖子

101

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
89
发表于 2022-7-6 22:20:25 | 显示全部楼层
 
        First Question are you using Autocad or similar CAD ?
        and second issue please check the Option selected on Tools reference on Excel Development Area see picture
        224202vvb6o2bi3hhi23so.png
回复

使用道具 举报

2

主题

19

帖子

17

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 22:23:36 | 显示全部楼层
Where does the attribute list get saved so i can check which attributes i need to change?
         
        Also, is it possible to only change part of an attribute, e.g
         
        C####-E-000 to C1234-E-000
回复

使用道具 举报

18

主题

118

帖子

101

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
89
发表于 2022-7-6 22:26:26 | 显示全部楼层
All attributes are stored in AttributeList array, during routine debug you can check which is the attributes you need to change see picture above, check the properties AttributeList(XX).TAGSTRING for information on NAME of Attribute and AttributeList(XX).TEXSTRING for modification.
        For modification you can insert:
         
        If AttributeList(6).TEXTSTRING="C####-E-000" then ' DRAWINGNO SHALL BE at position 6 of AttributeList array check with debug.
            AttributeList(6).TEXTSTRING="C1234-E-000" 
        end if
        224205ziqy9nnh9nq1tif1.png
        Of course Attribute value it's a string so you can manipulate as you need, it's could be from excel cell value, or LEFT("XXX", CharPos) or MID, or RIGHT.
         
        I hope above could solve your issue.
         
回复

使用道具 举报

2

主题

19

帖子

17

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 22:29:59 | 显示全部楼层
I understand that you have to run the program and "watch" the attributes to see the full list of them all, but when i try , it doesn't appear in a list like what you get. I'm probably doing something wrong, i've not got much experience with VBA yet
回复

使用道具 举报

18

主题

118

帖子

101

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
89
发表于 2022-7-6 22:35:20 | 显示全部楼层
Ok let explain goto into editing of code on row  
  1. AttributeList = NewoblkRef.GetAttributes
and type function key F9 so you insert a break (you will see a red row) of procedure when it is running and will pass on that point of code. 
        Run the procedure and when break point will be reached click with right mouse button and select add watch option. 
        On VBA software you will have a debug windows where you can see the "watched" variable. Click on the + sign on visible variable on that window and you will have all properties of selected variable (see picture on previous post). 
        Search the attributes name in TAGSTRING property value, and then you can modify the TEXTSTRING property value for change it as I showed you before. 
回复

使用道具 举报

2

主题

19

帖子

17

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 22:36:22 | 显示全部楼层
I've followed those steps, but on the watch list, it says value is empty and there's no option for the plus icon 
224206gwz90t8tp90t94r4.png
回复

使用道具 举报

18

主题

118

帖子

101

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
89
发表于 2022-7-6 22:39:03 | 显示全部楼层
Let the procedure execute the code in row because when you break on a specific row this will be not executed. 
        Press F8 function key and watch again. And press F5 to run again until next breakpoint will be reached again. 
         
回复

使用道具 举报

2

主题

19

帖子

17

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 22:42:35 | 显示全部楼层
Thanks Peter, I can see that now. I'm going to try and edit the values now.
         
        Your help has been invaluable! 
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 16:26 , Processed in 0.688174 second(s), 72 queries .

© 2020-2025 乐筑天下

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