Jump to content

LISP to make a selected text style current


SN00PY

Recommended Posts

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

Link to comment
Share on other sites

(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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...