After you have bound an XREF to a drawing you know the nastiness that comes into your drawing – Layers, Blocks and styles now a have a prefix added to the front of their names.
This routine (I wish I knew who to give credit to…) removes these prefixes from a number of objects/entities after you have bound them to your drawing. These objects include:
- Layers
- Blocks
- Styles (various, text dimensions…)
- UCS
- Saved Views
Here’s how:
After using the BIND command to bind an XREF
- RBP <enter> to start Remove Bind Prefixes
That’s it…
~enjoy
(defun c:RBP(/ ActDoc Name NewName) ; RemoveBindPrefixes ; Renames layers, blocks, dimension styles, text styles, user coordinate systems, and views ; by taking out the bind as bind prefix ; Example Drawing1$0$Layer1 -> Layer1 (vl-load-com) (defun RemoveBindPrefix (String / Pos LastPos) (if (setq Pos (vl-string-search "$" String)) (progn (setq LastPos Pos) (while (setq Pos (vl-string-search "$" String (1+ Pos))) (setq LastPos Pos) ) (substr String (+ 2 LastPos)) ) String ) ) ;--------------------------------------------------------- (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object))) (vlax-for Obj (vla-get-Layers ActDoc) (setq Name (vla-get-Name Obj)) (if (/= (setq NewName (RemoveBindPrefix Name)) Name) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Name (list Obj NewName))) (prompt (strcat "\n Layer: " Name " was not renamed.")) ) ) ) (vlax-for Obj (vla-get-Blocks ActDoc) (setq Name (vla-get-Name Obj)) (if (/= (setq NewName (RemoveBindPrefix Name)) Name) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Name (list Obj NewName))) (prompt (strcat "\n Block: " Name " was not renamed.")) ) ) ) (vlax-for Obj (vla-get-TextStyles ActDoc) (setq Name (vla-get-Name Obj)) (if (/= (setq NewName (RemoveBindPrefix Name)) Name) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Name (list Obj NewName))) (prompt (strcat "\n Text style: " Name " was not renamed.")) ) ) ) (vlax-for Obj (vla-get-Views ActDoc) (setq Name (vla-get-Name Obj)) (if (/= (setq NewName (RemoveBindPrefix Name)) Name) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Name (list Obj NewName))) (prompt (strcat "\n View: " Name " was not renamed.")) ) ) ) (vlax-for Obj (vla-get-UserCoordinateSystems ActDoc) (setq Name (vla-get-Name Obj)) (if (/= (setq NewName (RemoveBindPrefix Name)) Name) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Name (list Obj NewName))) (prompt (strcat "\n UCS: " Name " was not renamed.")) ) ) ) (vlax-for Obj (vla-get-DimStyles ActDoc) (setq Name (vla-get-Name Obj)) (if (/= (setq NewName (RemoveBindPrefix Name)) Name) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-Name (list Obj NewName))) (prompt (strcat "\n Dimension style: " Name " was not renamed.")) ) ) ) (princ) )
Hi,
Thanks for your lisp for delete prefix from layers on simple drawing.
However, it doesn’t work on complex drawing blinded with many drawings and each drawing contain the same layers.
For Example:
XE_36918_Fen_T1_Level7$0$A-Door
XE_36918_Fen_T1_Level9-17$0$A-Door
XE-36918-CORE-COM-L07$0$A-Door
XE-36918-CORE-COMM-MECH-ELEC SHAFT$0$A-Door
XE-36918-CORE-RES_L07$0$A-Door
XE-36918-EXIT STAIR 4_L4-7$0$A-Door
XE-36918-T1_Type C$0$A-Door
Is it possible to merge or combine those layer as one layer?
Can it also apply to suffix?
A lots of thanks
Aldrin
you just add this line:
(vl-cmdf “_.-laymrg” “_n” Name “” “_n” NewName “_y”)
before the line :
(prompt (strcat “\n Layer: ” Name ” was not renamed.”))
and it should merge the layers when they exist already
Does this work for xreffed then bound Linestyles as well? I noticed a Hidden Linestyle in your demo, it did not get renamed. Thanks
It didn’t work at all for me. Any updates to this lip?