fraidy Posted November 11, 2010 Share Posted November 11, 2010 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 Quote Link to comment Share on other sites More sharing options...
Dana W Posted November 11, 2010 Share Posted November 11, 2010 Use the Purge command, then the ties to the old style will be gone. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted November 11, 2010 Share Posted November 11, 2010 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! 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.