Jump to content

Change text style within blocks


Corro

Recommended Posts

Good Morning All

I have been try to write a lisp routine to convert old text styles to the new text style within inserted blocks.

This a part of a larger routine to clean up old drawings.

I am trying to select the blocks within the drawing and ten get it to select only text or mtext, but I am receiving every object within the drawing.

What am I going wrong?????

Attached is lisp routine and simple sample drawing.

Using AutoCAD 2017.

Thank you for any help.

Steve

000 test 12.lsp

X_STRCT1.dwg

Link to comment
Share on other sites

A better approach would be to redefine the individual block in the block table ie at the top of the tree and then just update the drawing, rather than get all blocks. which ssget "insert" is doing.

 

Something like this but look at the entity and check for text or mtext and change style. I would get the entity name and run a series of conds, as text & mtext are pretty staright forward but attributes styles are a level lower again but you can check the "Hasattributes" variable and then search deeper. You can use dumpit.lsp to get a list of the variable names of an object, then you go further using (vlax-dump-object variable)

 

(setq allblocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
(vlax-for block allblocks 
(setq blkname (vla-get-name block))
(if  (not (wcmatch (strcase blkname t) "*_space*")) 
   (vlax-for ent block 
     (If (= "AcDbText" (vla-get-objectname ent))
     (vla-put-StyleName ent "arial") ; need a vla-put-textstyle here
     ) ; if
   ) ;_ end of vlax-for 
) ;_ end of if
) ;_ end of vlax-for
(Command "regen")
(princ)

 

 
(if (= (vla-get-hasattributes ent) -1)
(foreach att (vlax-invoke ent 'getattributes)
;look at textstyle see if I can find an example  

Edited by BIGAL
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...