找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1777|回复: 9

[LISP程序]:块属性编辑程序

[复制链接]
发表于 2003-6-9 13:48:26 | 显示全部楼层 |阅读模式

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

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

×
;;;块属性编辑程序
;;;编写:HQD9639
;;;2003/6/9
(DEFUN DTR (DEG / )
  (* PI (/ DEG 180.0)))
;---------------------------------
(DEFUN RTD (RAD / )
  (/ (* 180.0 RAD) PI))
;-------------------------------
(defun c:chattdef ()
  (vl-load-com)
  (setq k T)
  (while k
            (setq  entbatt  (entsel "\n选取带属性图块: <退出>: "))
            (if  entbatt
                (progn
                      (setq entbatt (car  entbatt))                     
                     (setq wattvla (vlax-ename->vla-object entbatt))   
                     (setq name1 (vla-get-objectname wattvla))
                     (if (= name1 "AcDbBlockReference")
                          (progn
                                (if (=  (vla-get-HasAttributes wattvla) :vlax-true)
                                    (progn
                                          (setq attlst  (vlax-safearray->list  (vlax-variant-value (vla-getattributes wattvla))))
                                          (initget  "Value Height Width Rotation Font Layer Color Exit")
                                          (setq x0  (getkword "\n[Value//Height/Width/Rotation/Font/Layer/Color/Exit] <Exit>: "))
                                          (cond ((eq x0 "Value")
                                                      (if (> (length attlst) 1)
                                                           (progn
                                                                (initget  "Single All")
                                                                (setq y0  (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
                                                                (cond ((= y0 "Single")
                                                                            (setq mm 0)
                                                                            (repeat (length attlst)                                                                  
                                                                                       (setq ent  (nth mm attlst))
                                                                                       (setq enttxt  (vla-get-TextString ent))
                                                                                       (setq newstr (getstring (strcat  "\n请输入新属性值<"  enttxt  ">:")))
                                                                                       (if (eq ""  newstr) (setq newstr enttxt))                                             
                                                                                       (vla-put-TextString ent newstr )
                                                                                       (setq mm (1+ mm))
                                                                            )
                                                                          )
                                                                          ((= y0 "All")                                                                        
                                                                            (setq newstr (getstring "\n请输入新属性值:"))
                                                                            (foreach n attlst  (vla-put-TextString n newstr ))
                                                                         )
                                                                 );cond
                                                           )
                                                           (progn
                                                                (setq newstr (getstring "\n请输入新属性值:"))
                                                                (foreach n attlst  (vla-put-TextString n newstr ))
                                                           )
                                                      );if
                                                    )
                                                    ((eq x0 "Height")
                                                      (if (> (length attlst) 1)
                                                           (progn
                                                                (initget  "Single All")
                                                                (setq y0  (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
                                                                 (if (not y0) (setq y0 "All"))
                                                                (cond ((= y0 "Single")
                                                                            (setq mm 0)
                                                                            (repeat (length attlst)                                                                  
                                                                                       (setq ent  (nth mm attlst))
                                                                                       (setq enttxt  (vla-get-TextString ent))
                                                                                       (setq enthei  (vla-get-Height ent))
                                                                                       (initget 4)                                                                                      
                                                                                       (setq newstr (getreal (strcat  "\n请输入属性{ " enttxt  " }新高度<"   (rtos enthei)  ">:")))
                                                                                       (if (not newstr) (setq newstr enthei))
                                                                                       (vla-put-Height ent newstr )
                                                                                       (setq mm (1+ mm))
                                                                            )
                                                                          )
                                                                          ((= y0 "All")                                                                        
                                                                            (initget 5)                                                                                      
                                                                            (setq newstr (getreal (strcat  "\n请输入属性新高度: ")))                                      
                                                                            (foreach n attlst  (vla-put-Height n newstr ))
                                                                         )
                                                                 );cond
                                                           )
                                                           (progn
                                                                    (initget 5)                                                                                      
                                                                    (setq newstr (getreal (strcat  "\n请输入属性新高度: ")))                                      
                                                                    (foreach n attlst  (vla-put-Height n newstr ))
                                                           )
                                                      );if
                                                    )
                                                    ((eq x0 "Width")
                                                      (if (> (length attlst) 1)
                                                           (progn
                                                                (initget  "Single All")
                                                                (setq y0  (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
                                                                 (if (not y0) (setq y0 "All"))
                                                                (cond ((= y0 "Single")
                                                                            (setq mm 0)
                                                                            (repeat (length attlst)                                                                  
                                                                                       (setq ent  (nth mm attlst))
                                                                                       (setq enttxt  (vla-get-TextString ent))
                                                                                       (setq entwei  (vla-get-ScaleFactor ent))
                                                                                       (initget 4)                                                                                      
                                                                                       (setq newstr (getreal (strcat  "\n请输入属性{ " enttxt  " }新宽度<"   (rtos entwei)  ">:")))
                                                                                       (if (not newstr) (setq newstr entwei))
                                                                                       (vla-put-ScaleFactor ent newstr )
                                                                                       (setq mm (1+ mm))
                                                                            )
                                                                          )
                                                                          ((= y0 "All")                                                                        
                                                                            (initget 7)                                                                                      
                                                                            (setq newstr (getreal "\n请输入属性新宽度: "))                                 
                                                                            (foreach n attlst  (vla-put-ScaleFactor n newstr ))
                                                                         )
                                                                 );cond
                                                           )
                                                           (progn
                                                                    (initget 7)                                                                                      
                                                                    (setq newstr (getreal "\n请输入属性新宽度: "))                                    
                                                                    (foreach n attlst  (vla-put-ScaleFactor n newstr ))
                                                           )
                                                      );if
                                                    )
                                                    ((eq x0 "Rotation")
                                                      (if (> (length attlst) 1)
                                                           (progn
                                                                (initget  "Single All")
                                                                (setq y0  (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
                                                                 (if (not y0) (setq y0 "All"))
                                                                (cond ((= y0 "Single")
                                                                            (setq mm 0)
                                                                            (repeat (length attlst)                                                                  
                                                                                       (setq ent  (nth mm attlst))
                                                                                       (setq enttxt  (vla-get-TextString ent))
                                                                                       (setq entrot  (vla-get-Rotation ent))
                                                                                       (setq entrot0  (rtd (vla-get-Rotation ent)))
                                                                                       (setq newstr (getangle (strcat  "\n请输入属性{ " enttxt  " }新旋转角度<"   (rtos entrot0)  ">:")))
                                                                                       (if (not newstr) (setq newstr entrot))
                                                                                       (vla-put-Rotation ent newstr )
                                                                                       (setq mm (1+ mm))
                                                                            )
                                                                          )
                                                                          ((= y0 "All")                                                                        
                                                                            (initget 1)                                                                                      
                                                                            (setq newstr (getangle "\n请输入属性新转角度: "))                                   
                                                                            (foreach n attlst  (vla-put-Rotation n newstr ))
                                                                         )
                                                                 );cond
                                                           )
                                                           (progn
                                                                    (initget 1)                                                                                      
                                                                    (setq newstr (getangle "\n请输入属性新转角度: "))                                    
                                                                    (foreach n attlst  (vla-put-Rotation n newstr ))
                                                           )
                                                      );if
                                                    )
                                                    ((eq x0 "Font")
                                                      (if (> (length attlst) 1)
                                                           (progn
                                                                (initget  "Single All")
                                                                (setq y0  (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
                                                                (if (not y0) (setq y0 "All"))
                                                                (cond ((= y0 "Single")
                                                                            (setq mm 0)
                                                                            (repeat (length attlst)                                                                  
                                                                                       (setq ent  (nth mm attlst))
                                                                                       (setq enttxt  (vla-get-TextString ent))
                                                                                       (setq entsty  (vla-get-StyleName ent))
                                                                                       (setq newstr (getstring (strcat  "\n请输入属性{ " enttxt " }新字型<"  entsty  ">:")))
                                                                                       (if (eq ""  newstr) (setq newstr entsty))                                             
                                                                                       (vla-put-StyleName ent newstr )
                                                                                       (setq mm (1+ mm))
                                                                            )
                                                                          )
                                                                          ((= y0 "All")
                                                                            (initget 1)                                                                     
                                                                            (setq newstr (getstring "\n请输入属性新字型<Standard>:"))
                                                                            (if (eq "" newstr) (setq newstr "Standard"))
                                                                            (foreach n attlst  (vla-put-StyleName n newstr ))
                                                                         )
                                                                 );cond
                                                           )
                                                           (progn
                                                                (setq newstr (getstring "\n请输入属性新字型<Standard>:"))
                                                                (if (eq "" newstr) (setq newstr "Standard"))
                                                                (foreach n attlst  (vla-put-StyleName n newstr ))
                                                           )
                                                      );if
                                                    )
                                                    ((eq x0 "Layer")
                                                      (if (> (length attlst) 1)
                                                           (progn
                                                                (initget  "Single All")
                                                                (setq y0  (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
                                                                (if (not y0) (setq y0 "All"))
                                                                (cond ((= y0 "Single")
                                                                            (setq mm 0)
                                                                            (repeat (length attlst)                                                                  
                                                                                       (setq ent  (nth mm attlst))
                                                                                       (setq enttxt  (vla-get-TextString ent))
                                                                                       (setq entlay  (vla-get-Layer ent))
                                                                                       (setq newstr (getstring (strcat  "\n请输入属性{ " enttxt " }所在新层<"  entlay  ">:")))
                                                                                       (if (eq ""  newstr) (setq newstr entlay))                                             
                                                                                       (vla-put-Layer ent newstr )
                                                                                       (setq mm (1+ mm))
                                                                            )
                                                                          )
                                                                          ((= y0 "All")
                                                                            (setq newstr (getstring "\n请输入属性所在新层<0>:"))
                                                                            (if (eq "" newstr) (setq newstr "0"))
                                                                            (foreach n attlst  (vla-put-Layer n newstr ))
                                                                         )
                                                                 );cond
                                                           )
                                                           (progn
                                                               (setq newstr (getstring "\n请输入属性所在新层<0>:"))
                                                                (if (eq "" newstr) (setq newstr "0"))
                                                                (foreach n attlst  (vla-put-Layer n newstr ))
                                                           )
                                                      );if
                                                    )
                                                    ((eq x0 "Color")
                                                      (if (> (length attlst) 1)
                                                           (progn
                                                                (initget  "Single All")
                                                                (setq y0  (getkword "\n [单个改变(Single) /全部(All)]<All>: "))
                                                                (if (not y0) (setq y0 "All"))
                                                                (cond ((= y0 "Single")
                                                                            (setq mm 0)
                                                                            (repeat (length attlst)                                                                  
                                                                                       (setq ent  (nth mm attlst))
                                                                                       (setq enttxt  (vla-get-TextString ent))
                                                                                       (setq entcor (vla-get-Color ent))
                                                                                       (setq k1 T)
                                                                                       (while k1
                                                                                              (initget 4)                                                                                      
                                                                                              (setq newstr (getint (strcat  "\n请输入属性{ " enttxt  " }新颜色<"   (itoa entcor)  ">:")))
                                                                                              (if ( or (and (>= newstr 0) (<= newstr 256)) (eq nil newstr))
                                                                                                   (setq k1 nil)
                                                                                               )
                                                                                       )            
                                                                                       (if (not newstr) (setq newstr entcor))                                             
                                                                                       (vla-put-Color ent newstr )
                                                                                       (setq mm (1+ mm))
                                                                            )
                                                                          )
                                                                          ((= y0 "All")
                                                                            (setq k1 T)
                                                                            (while k1
                                                                                      (initget 5)                                                                                      
                                                                                      (setq newstr (getint  "\n请输入属性新颜色: "))
                                                                                      (if (and (>= newstr 0) (<= newstr 256))
                                                                                                (setq k1 nil)
                                                                                        )
                                                                           )
                                                                            (foreach n attlst  (vla-put-Color n newstr ))
                                                                         )
                                                                 );cond
                                                           )
                                                           (progn
                                                                    (setq k1 T)
                                                                     (while k1
                                                                                      (initget 5)                                                                                      
                                                                                      (setq newstr (getint  "\n请输入属性新颜色: "))
                                                                                      (if (and (>= newstr 0) (<= newstr 256))
                                                                                                (setq k1 nil)
                                                                                       )
                                                                  )
                                                                   (foreach n attlst  (vla-put-Color n newstr ))
                                                           )
                                                      );if
                                                    )
                                                    (T (setq k nil))
                                         );cond                                    
                                    );progn
                               ) ;if               
                          );progn
                     );if
               );progn
               (setq k nil)
         );if
  );while
  (princ)
);end
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2003-6-10 05:36:51 | 显示全部楼层
试了一下, 怎么字体改不了呀? 如 ROMAND->ROMANS ?
另: 能添加新的属性?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2005-2-17 23:30:50 | 显示全部楼层
最主要是能更改字体或字样
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 987个

财富等级: 财运亨通

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

使用道具 举报

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

使用道具 举报

发表于 2005-11-26 09:18:41 | 显示全部楼层
在r14中执行后的反馈是:
error: null function
(VL-LOAD-COM)
是否不适用于r14?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2005-11-30 18:53:49 | 显示全部楼层
超强的命令,不知能否修改一下选择方式(entsel "\n选取带属性图块: <退出>: "));entsel只接受点,某些时候用起来受限制。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

使用道具 举报

已领礼包: 35个

财富等级: 招财进宝

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

使用道具 举报

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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-17 02:59 , Processed in 0.427816 second(s), 50 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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