乐筑天下

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

[编程交流] using -dataextraction to searc

[复制链接]

4

主题

15

帖子

11

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 22:53:22 | 显示全部楼层 |阅读模式
Hello all,
 
 
I am attempting to extract a list of all blocks and their attributed text into excel (from which to build a BOM). Using the dataextraction commands works, but there are a lot of button clicks (aka places where users could get confused or click the wrong thing).
 
 
I tried using -dataextraction, but for some reason using the command line version does not let me search for objects in the current drawing. Opening the extraction wizard confirms this - whenever I load a template, even if I selected "also search in current drawing" when making it, it's unchecked by default.
 
 
 
 
Something like Lee Mac's program MacAtt might work, but it doesn't have a command line version.
 
 
I've also tried using the code from this thread http://www.cadtutor.net/forum/showthread.php?50663-Data-Extraction
but upon running it, I get "error: quit / exit abort"
 
 
I'm thinking there is a way to do what I want through the "ATTEXT" command, but every time I try to use it, it says "0 records in extract file" and the output file is blank.
 
 
Anyone have ideas about what else I can try?
回复

使用道具 举报

4

主题

15

帖子

11

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 23:06:12 | 显示全部楼层
Update:
 
 
I think I have a working solution. First I save the workbook to the dxf format, then I use autolisp to open a macro-enabled excel sheet and execute a macro, then I use VBA within excel to open the dxf and look for lines that say "AcDbBlockReference" and extract the data two lines below that, then delete everything else I don't need and save the workbook.
 
 
It's very slow and very crude but it gets the job done. If possible, I would like to know more about the AcDbBlockReference in the dxf format... Does anyone know if this is a reliable way of finding block names?
 
 
Again, if anyone has suggestions on a better way of doing this, I'm all ears. All I want it a list of block names in the current drawing, yet this ugly mess is the only was I've been able to do it :/
回复

使用道具 举报

10

主题

598

帖子

594

银币

初来乍到

Rank: 1

铜币
48
发表于 2022-7-5 23:22:07 | 显示全部楼层
ATTEXT should work, providing your blocks do contain attributes, and your extraction template file is correct, can you post a sample drawing and a copy of your extraction template. I can take a look tomorrow, but someone else might be able to help with those available. I run a macro that extracts all block names and attributes with just one click, and places the output into a csv file.
回复

使用道具 举报

4

主题

15

帖子

11

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 23:36:22 | 显示全部楼层
My blocks do not contain attributes (at least, not any that I have specified) other than their name.
 
 
I can't seem to attach the template but I did attach the output (basically, it's the template you get by choosing all default options and only exporting "Author". I chose "Author" arbitrarily - I don't need to export any attributes at all; I only care about names and quantities, but I can't click next unless some attribute is checked.)
test drawing.dwg
test drawing.xls
回复

使用道具 举报

10

主题

598

帖子

594

银币

初来乍到

Rank: 1

铜币
48
发表于 2022-7-5 23:47:58 | 显示全部楼层
The problem you are having with ATTEXT is because it expects blocks to contain at least one attribute that it can read the tag name from that is listed in the template file, and it can only read attributes who's tag name is listed. I think DATAEXTRACTION works differently but I don't have access to that from LT.
Once a block contains at least 1 valid attribute, you can export quite a bit of information from the blocks such as name, layer, position. Take a look at the attached blocks and template file, with something like this you can setup a toolpalette macro to extract all block information from an entire drawing (into a csv file) with just one mouse click, which can easily be imported into excel.
ext.txt
test drawing.dwg
回复

使用道具 举报

4

主题

15

帖子

11

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 00:05:25 | 显示全部楼层
Can you use EATTEXT? In AutoCAD electrical, that command does exactly the same thing as DATAEXTRACTION.
 
 
Ah ok, I didn't realize that ATTEXT required that. ATTEXT may not be suitable then because it would require an extra step of adding an attribute to every block... as people are adding blocks to the library, I'm sure they'll forget at some point, and then the BOM will be missing items and they won't realize it. Unless there is a command to first add an attribute to every block, then extract the data. Is there such a command? Using -ATTDEF just returns "That block has no editable attributes.".
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-11 03:21 , Processed in 1.038539 second(s), 64 queries .

© 2020-2025 乐筑天下

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