Mater
2011-04-27, 06:08 PM
I'm looking for some help. I came across this lisp routine and tried to modify it to select every object on the "Labels" layer. I keep getting this error:
ActiveX Server returned the error: unknown name: STYLENAME
The original code I found had the code below at line 2 but the user has to select the objects
(setq ss1 (ssget (list (cons 0 "*text")))
I would like the lisp to select all the text on the labels layer without user input other than the style that they want to change the text too. Here is the modified lisp in it's entirety:
(defun c:ft ( / ss1 index newstyle styledata defwidth ename txtobj)
(setq ss1 (ssget "x" '((8 . "Labels") ))
index 0
newstyle (getstring "\nEnter new style for text: ")
)
(if (setq styledata (tblsearch "style" newstyle))
(progn
(setq defwidth (cdr (assoc 41 styledata)))
(while (setq ename (ssname ss1 index))
(setq txtobj (vlax-ename->vla-object ename))
(vlax-put-property txtobj 'StyleName newstyle)
(if (vlax-property-available-p txtobj 'ScaleFactor)
(vlax-put-property txtobj 'ScaleFactor defwidth)
)
(setq index (1+ index))
)
)
(princ "\nRequested text style does not exist!")
)
(princ)
)
Thanks
ActiveX Server returned the error: unknown name: STYLENAME
The original code I found had the code below at line 2 but the user has to select the objects
(setq ss1 (ssget (list (cons 0 "*text")))
I would like the lisp to select all the text on the labels layer without user input other than the style that they want to change the text too. Here is the modified lisp in it's entirety:
(defun c:ft ( / ss1 index newstyle styledata defwidth ename txtobj)
(setq ss1 (ssget "x" '((8 . "Labels") ))
index 0
newstyle (getstring "\nEnter new style for text: ")
)
(if (setq styledata (tblsearch "style" newstyle))
(progn
(setq defwidth (cdr (assoc 41 styledata)))
(while (setq ename (ssname ss1 index))
(setq txtobj (vlax-ename->vla-object ename))
(vlax-put-property txtobj 'StyleName newstyle)
(if (vlax-property-available-p txtobj 'ScaleFactor)
(vlax-put-property txtobj 'ScaleFactor defwidth)
)
(setq index (1+ index))
)
)
(princ "\nRequested text style does not exist!")
)
(princ)
)
Thanks