CAD块属性提取

安排的任务早早的完成了
上级又都出差了,别人的活也没发帮忙
上班就只好写点小程序简化工作流程
别看程序不大内容还挺多
物料统计辅助程序:
 
程序介绍:

1.       提取AutoCAD图像中的物料信息CADRead.exe

2.       数据库BOM.mdb

3.       写入标记块CADWrite.exe

 
使用方法:
首先要配合AutoCAD中块 ITEM_NUMBER_Metric
画图填写该块的时候需按照以上格式填写
  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
Lisp(LISt Processing)是一种编程语言,常被用于自动化CAD软件的开发与扩展。对于提取CAD中的所有属性,可以使用Lisp编写程序来完成。 在CAD软件中,(Block)是一种重要的元素,它可以将多个实体对象组合成一个整体,并赋予其唯一的标识符和属性可以包含属性,这些属性可以用于进一步描述和标识。 要提取CAD中的所有属性,可以按照以下步骤进行操作: 1. 在Lisp中,使用`(ssget)`函数选择所有的对象,将其保存在一个选择集中。 2. 遍历选择集,使用`(entget)`函数逐个获取每个对象的详细信息。 3. 对于每个对象,使用`(entget)`函数获取其属性列表。 4. 遍历属性列表,使用`(cdr)`函数逐个提取每个属性的键值对。 5. 将提取到的属性信息进行处理和保存,可以输出到控制台或者写入文件中。 下面是一个简单的示例代码,用于在AutoCAD软件中提取CAD中的所有属性: ```lisp (defun extract-block-attributes () (setq block-ss (ssget "X" '((0 . "INSERT")))) (setq block-count (sslength block-ss)) (setq attribute-list '()) (repeat block-count (setq block (ssname block-ss (setq i (1+ i)))) (setq attribute-ss (ssget "X" (list '(0 . "ATTRIB") (cons 2 (cdr (assoc 2 (entget block))))))) (setq attribute-count (sslength attribute-ss)) (setq j 0) (repeat attribute-count (setq attribute (ssname attribute-ss (setq j (1+ j)))) (setq attribute-data (entget attribute)) (setq attribute-list (append attribute-list (list attribute-data))) ) ) (setq attribute-count (length attribute-list)) (repeat attribute-count (setq attribute-data (nth (setq i (1+ i)) attribute-list)) (princ (cdr (assoc 2 attribute-data))) ; 输出属性名称 (princ ": ") (princ (cdr (assoc 1 attribute-data))) ; 输出属性值 (princ) ; 换行 ) ) ``` 上述代码通过`(ssget)`函数选择所有对象,然后使用`(ssget)`函数再次选择对应的属性对象。通过遍历属性列表,再分别提取属性的键名和键值,并逐个输出。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值