乐筑天下

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

(defun c:addatts

[复制链接]

26

主题

345

帖子

11

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
448
发表于 2003-8-18 09:38:00 | 显示全部楼层 |阅读模式
(defun c:addatts (/ oecho blkName tagName ss totVal index en val txtPt)
   ;;
   ;;subroutine to extract attribute value from a block
   ;;
     (defun attval (ins att / attnam val)
        (while (and
                 (/= attnam att)
                 (/= (cdr (assoc 0 (entget ins))) "SEQEND")
               )
               (setq attnam (cdr (assoc 2 (entget ins))))
               (if (= attnam att)
                   (setq val (cdr (assoc 1 (entget ins))))
               )
               (setq ins (entnext ins))
        )
        (eval val)
     );end attval
   ;;
   ;;start of main 'addatts' function
   ;;
     (setq
       oecho (getvar "cmdecho")
       blkName (strcase (getstring "\nBlock name: "))
       tagName (strcase (getstring "\nTag name to total: "))
       ss (ssget "x" (list '(0 . "insert")(cons 2 blkName)))
       totVal 0
       index 0
     )
     (setvar "cmdecho" 0)
     (cond
       ((not ss)
        (princ "\nInvalid block name.")
       )
       ((not (attval (ssname ss index) tagName))
        (princ "\nInvalid attribute tag.")
       )
       (T
        (repeat (sslength ss)
          (setq
            en (ssname ss index)
            val (distof (attval en tagName))
            index (1+ index)
          )
          (if val (setq totVal (+ totVal val)))
        );end repeat
        (setq
          totVal (rtos totVal)
          txtPt (getpoint "\nInsertion point for total value: ")
        )
        (command
          "._text"
          "middle"
           txtpt
        )
        (if (= 0.0 (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))))
           (command "" "" totVal)
           (command "" totVal)
        )
       )
     );end cond
     (setvar "cmdecho" oecho)
     (princ)
   );end addatts
回复

使用道具 举报

11

主题

80

帖子

9

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
124
发表于 2003-8-18 13:33:00 | 显示全部楼层
此程序有何功能,能解释一下吗?
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-4 21:27 , Processed in 1.690783 second(s), 56 queries .

© 2020-2025 乐筑天下

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