找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 582|回复: 2

[每日一码] 修改MLEADER的属性块的值

[复制链接]

已领礼包: 19个

财富等级: 恭喜发财

发表于 2017-5-20 23:01:59 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
  1. ;;---------=={ Set MLeader Block Attribute Value }==----------;;
  2. ;;                                                            ;;
  3. ;;  Sets the value of the specified tag for the specified     ;;
  4. ;;  MLeader                                                   ;;
  5. ;;------------------------------------------------------------;;
  6. ;;  Author: Lee McDonnell, 2010                               ;;
  7. ;;                                                            ;;
  8. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  9. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  10. ;;------------------------------------------------------------;;
  11. ;;  Arguments:                                                ;;
  12. ;;  mleader - ename/VLA-Object MLeader with attributed block  ;;
  13. ;;  tag     - Tagstring of the attribute to change            ;;
  14. ;;  value   - Value to which attribute will be set            ;;
  15. ;;------------------------------------------------------------;;
  16. ;;  Returns:  nothing                                              ;;
  17. ;;------------------------------------------------------------;;


  18. (defun lm:_rjp_mod_setmleaderblockattributevalue (mleader value / def id exval)
  19.   (vl-load-com)
  20.   ;; © Lee Mac 2010
  21.   (if (and (eq "AcDbMLeader"
  22.                (vla-get-objectname
  23.                  (setq mleader (cond ((eq 'vla-object (type mleader)) mleader)
  24.                                      ((vlax-ename->vla-object mleader))
  25.                                )
  26.                  )
  27.                )
  28.            )
  29.            (= 1 (vla-get-contenttype mleader))
  30.            (setq def (lm:itemp (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
  31.                                (vla-get-contentblockname mleader)
  32.                      )
  33.            )
  34.       )
  35.     (vlax-for obj def
  36.       (if (eq "AcDbAttributeDefinition" (vla-get-objectname obj))
  37.         ;; RJP mod to get existing value and add a new value to it
  38.         (if (and (setq id (vla-get-objectid obj))
  39.                  (setq exval (vla-getblockattributevalue mleader id))
  40.             )
  41.           (vla-setblockattributevalue mleader id (vl-princ-to-string (+ value (atof exval))))
  42.         )
  43.       )
  44.     )
  45.   )
  46. )
  47. ;;-----------------------=={ Itemp }==------------------------;;
  48. ;;                                                            ;;
  49. ;;  Retrieves the item with index 'item' if present in the    ;;
  50. ;;  specified collection, else nil                            ;;
  51. ;;------------------------------------------------------------;;
  52. ;;  Author: Lee McDonnell, 2010                               ;;
  53. ;;                                                            ;;
  54. ;;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;
  55. ;;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;
  56. ;;------------------------------------------------------------;;
  57. ;;  Arguments:                                                ;;
  58. ;;  coll - the VLA Collection Object                          ;;
  59. ;;  item - the index of the item to be retrieved              ;;
  60. ;;------------------------------------------------------------;;
  61. ;;  Returns:  the VLA Object at the specified index, else nil ;;
  62. ;;------------------------------------------------------------;;
  63. (defun lm:itemp        (coll item)
  64.   ;; © Lee Mac 2010
  65.   (if
  66.     (not (vl-catch-all-error-p (setq item (vl-catch-all-apply (function vla-item) (list coll item))))
  67.     )
  68.      item
  69.   )
  70. )


  71. (defun c:test (/ e i n ss)
  72.   (if (and (setq n (getdist "\nEnter increment amount: "))
  73.            (setq ss (ssget ":L" '((0 . "multileader"))))
  74.       )
  75.     (repeat (setq i (sslength ss))
  76.       (lm:_rjp_mod_setmleaderblockattributevalue (ssname ss (setq i (1- i))) n)
  77.     )
  78.   )
  79. )
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 6468个

财富等级: 富甲天下

发表于 2017-5-21 00:15:38 | 显示全部楼层
谢谢分享。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复

使用道具 举报

已领礼包: 1304个

财富等级: 财源广进

发表于 2017-5-21 09:53:25 | 显示全部楼层
谢谢分享。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-5-27 02:45 , Processed in 0.378149 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表