SN00PY Posted September 23, 2013 Share Posted September 23, 2013 Hi all, does anyone know of a lisp routine that can set the current text style by selecting an existing inserted or modified text entity in the drawing? (Sorry, my title says Dimension when I meant TEXT) I'm new to the forum, but not AutoCAD and I'm self taught when it comes LISP. Any code suggestions would be greatly appreciated. Thanks in advance Quote Link to comment Share on other sites More sharing options...
Cad64 Posted September 23, 2013 Share Posted September 23, 2013 Welcome to the forum. I have renamed your thread and moved it to the AutoLisp section. For best results, always post in the appropriate area of the forum. Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 23, 2013 Share Posted September 23, 2013 (defun c:picktxtstyle ( / adoc ent st stcoll stobj ) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (while (not ent) (setq ent (car (entsel "\nPick text object that has TEXT STYLE property - DXF 7 code to make its style current"))) (if (not (assoc 7 (entget ent))) (progn (setq ent nil) (prompt "\nPicked entity doesn't have TEXT STYLE property, or missed selection; Try again...") ) ) ) (setq st (cdr (assoc 7 (entget ent)))) (setq stcoll (vla-get-textstyles adoc)) (setq stobj (vla-item stcoll st)) (vla-put-activetextstyle adoc stobj) (princ) ) (defun c:pckst nil (c:picktxtstyle)) M.R. Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted September 23, 2013 Share Posted September 23, 2013 Another, without using DXF 7 code - just Vlisp 'stylename property... (defun c:picktxtstyle ( / adoc ent st stcoll stobj ) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object))) (while (not ent) (setq ent (car (entsel "\nPick text object that has TEXT STYLE property - DXF 7 code to make its style current"))) (if (not (vlax-property-available-p (vlax-ename->vla-object ent) 'stylename)) (progn (setq ent nil) (prompt "\nPicked entity doesn't have TEXT STYLE property, or missed selection; Try again...") ) ) ) (setq st (vla-get-stylename (vlax-ename->vla-object ent))) (setq stcoll (vla-get-textstyles adoc)) (setq stobj (vla-item stcoll st)) (vla-put-activetextstyle adoc stobj) (princ) ) (defun c:pckst nil (c:picktxtstyle)) M.R. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.