乐筑天下

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

[编程交流] 添加属性值

[复制链接]

3

主题

11

帖子

8

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 22:16:22 | 显示全部楼层 |阅读模式
大家好。
我到处寻找例程,但没有成功,它可以在块“bar_1”中取两个属性“tag1”和“tag2”乘以这两个值,并将结果放在“tag3”的同一块中
有人能帮忙吗?
回复

使用道具 举报

4

主题

2143

帖子

2197

银币

限制会员

铜币
-24
发表于 2022-7-5 22:35:35 | 显示全部楼层
我创建了一个新线程
AutoLISP、Visual LISP和DCL>添加属性值
回复

使用道具 举报

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-5 22:43:01 | 显示全部楼层
这肯定是可行的,但需要更多的信息或样本-大卫
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 23:03:02 | 显示全部楼层
使用标记3中的公式字段,引用标记1和2中的值-不需要LISP。
回复

使用道具 举报

3

主题

11

帖子

8

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 23:15:01 | 显示全部楼层
谢谢你的回复。
我过去经常这么做
但不幸的是,目前我使用的是ZwCAD 2014,目前该程序不支持现场数学运算。
这就是为什么我需要将所有计算转移到lisp例程中。
完美的代码在开始时会有一个简单的设置,如块名、标记和如何进行计算以使其更通用的清晰想法。
我附上了一个基本想法的例子。
实例图纸
回复

使用道具 举报

3

主题

11

帖子

8

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 23:23:53 | 显示全部楼层
感谢李的网站,我做到了这一点:
我使用了不同的属性名称,但现在很容易更改
  1. ;;ver 1.0
  2. ;; cfany 2014.10.31
  3. (defun c:re3 ( / )
  4. (regen3)
  5. )
  6. (defun regen3 ( / idx lst2 ss1 zas roz mno dod ile zas_o roz_o mno_o dod_o )
  7.    (if
  8.        (and
  9.            (setq ss1 (ssget "X" '((0 . "INSERT") (2 . "BAR_T2") (66 . 1))));only  BAR_T2 blcks
  10.    
  11.            (setq zas "ZASIEG"
  12.                          roz "ROZ"
  13.                          mno "MNOZNIK"
  14.                          dod "DODATKOWY"
  15.                          ile "BAM")
  16.                 (repeat (setq idx (sslength ss1))
  17.                                 (setq idx (1- idx))       
  18.                                 (setq bname (ssname ss1 idx))
  19.                 ;                         (princ idx) (princ bname)                                                                                         
  20.            (setq zas_o (LM:getattributevalue bname zas))
  21.                 (setq roz_o (LM:getattributevalue bname roz))
  22.                 (setq mno_o (LM:getattributevalue bname mno))
  23.                 (setq dod_o (LM:getattributevalue bname dod))
  24.                 (setq lst2 (itoa (* (+ (/ (atoi zas_o) (atoi roz_o)) (atoi dod_o)) (atoi mno_o))))
  25.                 (LM:setattributevalue bname ile lst2)
  26.                 ;                (princ zas)        (princ "\n")
  27.                 )
  28.        )
  29.    (princ "\nZaktualizowano")
  30.    )
  31.    (princ)
  32. )
  33. ;; Set Attribute Value  -  Lee Mac
  34. ;; Sets the value of the first attribute with the given tag found within the block, if present.
  35. ;; blk - [ent] Block (Insert) Entity Name
  36. ;; tag - [str] Attribute TagString
  37. ;; val - [str] Attribute Value
  38. ;; Returns: [str] Attribute value if successful, else nil.
  39. (defun LM:setattributevalue ( blk tag val / enx )
  40.    (if (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk)))))))
  41.        (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
  42.            (if (entmod (subst (cons 1 val) (assoc 1 enx) enx))
  43.                (progn
  44.                    (entupd blk)
  45.                    val
  46.                )
  47.            )
  48.            (LM:setattributevalue blk tag val)
  49.        )
  50.    )
  51. )
  52. ;; Get Attribute Value  -  Lee Mac
  53. ;; Returns the value held by the specified tag within the supplied block, if present.
  54. ;; blk - [ent] Block (Insert) Entity Name
  55. ;; tag - [str] Attribute TagString
  56. ;; Returns: [str] Attribute value, else nil if tag is not found.
  57. (defun LM:getattributevalue ( blk tag / enx )
  58.    (if (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk)))))))
  59.        (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
  60.            (cdr (assoc 1 enx))
  61.            (LM:getattributevalue blk tag)
  62.        )
  63.    )
  64. )
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-11 06:12 , Processed in 0.408070 second(s), 64 queries .

© 2020-2025 乐筑天下

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