<FONT face=宋体>毋须EXplode,编辑属性块中属性的小工具. 此代码只是实现基本功能, 请大家试用!
(defun c:test ()
(vl-load-com)
(setq att (getstring "\nChange attribute [Angle/Color/Height/Layer/Position/Style/Value/Tagstring]: "))
(setq obj (car (nentsel "\nSelect an Attribute: ")))
(setq obj (vlax-ename->vla-object obj))
(cond
((= (strcase att) "A")
(setq ang (getstring t "\nNew Angle: "))
(vlax-put-property obj 'rotation ang))
((= (strcase att) "C")
(setq col (getstring "\nNew Color Number: "))
(vlax-put-property obj 'color col))
((= (strcase att) "H")
(setq ohei (vlax-get-property obj 'height))
(setq hei (getdist (strcat "\nNew Height <" (rtos oh 2 2) ">:")))
(if (= hei "")(setq hei ohei))
(vlax-put-property obj 'height hei))
((= (strcase att) "L")
(setq lay (getstring "\nNew Layer:"))
(if (not (tblsearch "LAYER" lay))
(alert (strcat "\nLayer " (strcase lay) " doesn't exist!"))
(vlax-put-property obj 'layer lay)
))
((= (strcase att) " ")
(setq pos (getpoint "\nNew Position:"))
(vlax-put-property obj 'textalignmentpoint (vlax-3d-point pos)))
((= (strcase att) "S")
(setq sty (getstring "\nNew Style: "))
(if (not (tblsearch "STYLE" sty))
(alert (strcat "\nThe style " (strcase sty) " doesn't exist!"))
(vlax-put-property obj 'stylename sty)
))
((= (strcase att) "V")
(setq val (getstring t "\nNew value: "))
(vlax-put-property obj 'textstring val))
);c
(princ)
);defun</FONT> |