Jump to content

Removing textstyles


fraidy

Recommended Posts

hi i'm changing all text inside dwg from textstyle to another one using vba and it works great, so when you see any text properties, you find the style of this text is the new one.

when i'm removing the old textstyle,a msg appear that this style is in use.

when i make a selection to all texts filtered by the old textstyle,the result appear that all text are selected even if they have a different style in their properties.

so i guess the old textstyle have a linked but i don't know how.

the result i need is to remove all texts to another style and delete the old textstyle

thks

Link to comment
Share on other sites

Use the Purge command, then the ties to the old style will be gone.

 

This will not work *IF* a dimension style references the text style the OP wants to delete. The purge window will place this text style in the 'Items you cannot purge' category.

 

For example:

 

(defun c:FOO (/ ss oldStyle newStyle stylesObj)
 (vl-load-com)
 (vla-startundomark
   (cond (*activeDoc*)
         ((setq *activeDoc*
                 (vla-get-activedocument (vlax-get-acad-object))))))

 ;; Replace text styles for all text and mtext
 (if (setq ss (ssget "_x"
                     (list '(0 . "TEXT,MTEXT")
                           (cons 7 (setq oldStyle "[color=red]Old[/color][color=red]TextStyleName_ToDelete[/color]")))))
   (progn
     (vlax-for x (setq ss (vla-get-activeselectionset *activeDoc*))
       (if (/= (setq newStyle "[color=red]NewTextStyleName[/color]") (vla-get-stylename x))
         (vla-put-stylename x newStyle)))
     (vla-delete ss)
     (setq stylesObj (vla-get-textstyles *activeDoc*))
     (vla-put-activetextstyle *activeDoc* (vla-item stylesObj newStyle))
     [color=blue](vla-delete (vla-item (vla-get-textstyles *activeDoc*) oldStyle))))[/color] [color=seagreen];<- This line will error[/color]
 (vla-endundomark *activeDoc*)
 (princ))

 

 

VLIDE Console output:

 

; error: Automation Error. Object is referenced by other object(s)
_$ 

 

 

In this situation, one will need to step through the DimStyles Object, and find the dimension style that references said text style, by filtering through the XData, and replace it (the text style) prior to being deleting/purged.

 

Hope this helps!

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