文件已成功删除: D:\wwwroot\forum\host.txt 晓东CAD家园-论坛-A/VLISP-[求助]:更改属性值?-用下面程序修改单属性块属性值为nc,出错,不知何故。(defun kk(/ ) (setq n (car(entsel))) (setq n1 (entnext n)) (setq dxf (entget n1)) (setq new (cons ... - Powered by Discuz!

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 652|回复: 4

[求助] [求助]:更改属性值?

[复制链接]
发表于 2003-7-22 16:17:02 | 显示全部楼层 |阅读模式

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

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

×
用下面程序修改单属性块属性值为nc,出错,不知何故。
(defun kk(/ )
  (setq n (car(entsel)))
  (setq n1 (entnext n))
  (setq dxf (entget n1))
  
  (setq new (cons 1 "nc"))
  (setq dxf (subst new (assoc 1 dxf) dxf))
  (entmod dxf)
  (entupd n1)
  )
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2003-7-22 16:50:48 | 显示全部楼层
谨供参考:


  1.   [FONT=courier new]
  2. (defun fld (num)
  3.    (cdr (assoc num d))
  4. )

  5. (defun C:ATEDIT (/ adj p l n e os as ns st s nsl osl sl si chf chm)
  6.    (setq p (ssget))     
  7.    (if p (progn                     
  8.       (setq osl (strlen (setq os (getstring "\nOld string: " t))))
  9.       (setq nsl (strlen (setq ns (getstring "\nNew string: " t))))
  10.       (setq l 0 chm 0 n (sslength p))
  11.       (setq adj
  12.          (cond
  13.             ((/= osl nsl) (- nsl osl))
  14.             (T nsl)
  15.          )
  16.       )
  17.       (while (< l n)               
  18.          (setq d (entget (setq e (ssname p l))))
  19.          (if (and (= (fld 0) "INSERT")
  20.                   (= (fld 66) 1))     
  21.                   (progn
  22.                      (setq e (entnext e))
  23.                      (while e
  24.                         (setq d (entget e))
  25.                         (cond ((= (fld 0) "ATTRIB")
  26.                            (setq chf nil si 1)
  27.                            (setq s (cdr (setq as (assoc 1 d))))
  28.                            (while (= osl (setq sl (strlen
  29.                                          (setq st (substr s si osl)))))
  30.                               (cond
  31.                                  ((= st os)
  32.                                     (setq s (strcat (substr s 1 (1- si)) ns
  33.                                                     (substr s (+ si osl))))
  34.                                     (setq chf t)   
  35.                                     (setq si (+ si adj)))
  36.                               )
  37.                               (setq si (1+ si))
  38.                            )
  39.                            (if chf (progn      
  40.                               (setq d (subst (cons 1 s) as d))
  41.                               (entmod d)        
  42.                               (entupd e)        
  43.                               (setq chm (1+ chm))
  44.                            ))
  45.                         (setq e (entnext e))
  46.                         )
  47.                         ((= (fld 0) "SEQEND")
  48.                            (setq e nil)) ; stop scan
  49.                         (T (setq e (entnext e)))
  50.                         );end cond
  51.                      );end while
  52.                   ) ;end progn
  53.           ) ;end if
  54.          (setq l (1+ l))
  55.       );end while
  56.    ))
  57.    (princ "Changed ")     
  58.    (princ chm)
  59.    (princ " attributes.")
  60.    (terpri)
  61. )
  62.   [/FONT]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-7-23 15:08:09 | 显示全部楼层
(defun c:changeattvalue ()
  (setq a (car (nentsel "\nSelect an Attribute: ")))
  (setq b (vlax-ename->vla-object a))
  (setq attv (getstring "Input New Value:"))
  (vlax-put-property b 'textstring attv)
  (princ)        
)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2003-7-23 19:43:01 | 显示全部楼层
我用第1贴中的程序,在单位的R14另一张图中用时运行正常,换出错的图仍是不行,弄了半天又行了,是不是
程序中少些什么,或是有什么变量控制?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 488个

财富等级: 日进斗金

发表于 2003-7-23 23:32:41 | 显示全部楼层
第一贴
除非(entupd n1)改为(entupd n),其他好像没错.

改属性我专门贴过的,找找.
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-9-26 14:25 , Processed in 0.190734 second(s), 48 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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