;;; Change all entities to colour white and layer "0" and purge all ;;; Note: Bind all Xrefs and Unlock and thaw all layers if you want it do a better job ;;; By Alvin Lin 28/09/2007 ;;; (defun C:GoWhite (/ doc blks txtstr atts) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (setq blks (vla-get-blocks doc)) (setvar "CLAYER" "0") (vlax-for blk blks (vlax-for obj blk (vla-put-color obj acWhite) (vla-put-layer obj "0") (if (= (vla-get-objectName obj) "AcDbMText") (progn (setq txtstr (vla-get-textstring obj)) (if (wcmatch txtstr "*\\C#*") (vla-put-textstring obj (UnFormat txtstr "C")) ) ) ) ; if (if (= (vla-get-objectName obj) "AcDbBlockReference") (if (= (vla-get-hasattributes obj) :vlax-true) (progn (setq atts (vlax-safearray->list (vlax-variant-value (vla-getattributes obj)) ) ) (foreach att atts (vla-put-color att acWhite) (vla-put-layer att "0") ) ) ) ;if ) ; if (if (= (vla-get-objectName obj) "AcDbLeader") (vla-put-DimensionLineColor obj acWhite) ) ; if ) ) (vla-purgeall doc) (princ) ) ; Unformat function written by John Uhden ; This version of Unformat has been modified for this application. ; ; Thank you John. ; ; ------------------------------------------------- ; ; Primary function to perform the format stripping: ; Arguments: ; Mtext - the text string to be Unformatted ; Formats - a string containing some or all of ; the following characters: ; ; A - Alignment ; C - Color ; F - Font ; H - Height ; L - Underscore ; O - Overscore ; P - Linefeed (Paragraph) ; Q - Obliquing ; S - Spacing (Stacking) ; T - Tracking ; W - Width ; ~ - Non-breaking Space ; Optional Formats - ; * - All formats ; Returns: ; nil - if not a valid Mtext object ; Text - the Mtext textstring with none, some, or all ; of the formatting removed, depending on what ; formats were present and what formats were ; specified for removal. ; (defun UnFormat (Mtext Formats / All Format1 Format2 Text Str) (and Mtext Formats (= (type Mtext) 'STR) (= (type Formats) 'STR) (setq Formats (strcase Formats)) (setq Text "") (setq All T) (if (= Formats "*") (setq Formats "S" Format1 "\\[LO`~]" Format2 "\\[ACFHQTW]" Format3 "\\P" ) (progn (setq Format1 "" Format2 "" Format3 "" ) (foreach item '("L" "O" "~") (if (vl-string-search item Formats) (setq Format1 (strcat Format1 "`" item)) (setq All nil) ) ) (if (= Format1 "") (setq Format1 nil) (setq Format1 (strcat "\\[" Format1 "]")) ) (foreach item '("A" "C" "F" "H" "Q" "T" "W") (if (vl-string-search item Formats) (setq Format2 (strcat Format2 item)) (setq All nil) ) ) (if (= Format2 "") (setq Format2 nil) (setq Format2 (strcat "\\[" Format2 "]")) ) (if (vl-string-search "P" Formats) (setq Format3 "\\P") (setq Format3 nil All nil ) ) T ) ) (while (/= Mtext "") (cond ((wcmatch (strcase (setq Str (substr Mtext 1 2))) "\\[\\{}]") (setq Mtext (substr Mtext 3) Text (strcat Text Str) ) ) ((and All (wcmatch (substr Mtext 1 1) "[{}]")) (setq Mtext (substr Mtext 2)) ) ((and Format1 (wcmatch (strcase (substr Mtext 1 2)) Format1)) (setq Mtext (substr Mtext 3)) ) ((and Format2 (wcmatch (strcase (substr Mtext 1 2)) Format2)) (setq Mtext (substr Mtext (+ 2 (vl-string-search ";" Mtext)))) ) ((and Format3 (wcmatch (strcase (substr Mtext 1 2)) Format3)) (if (or (= " " (substr Text (strlen Text))) (= " " (substr Mtext 3 1)) ) (setq Mtext (substr Mtext 3)) (setq Mtext (substr Mtext 3) Text (strcat Text " ") ) ) ) ((and (vl-string-search "S" Formats) (wcmatch (strcase (substr Mtext 1 2)) "\\S") ) (setq Str (substr Mtext 3 (- (vl-string-search ";" Mtext) 2)) Text (strcat Text (vl-string-translate "#^\\" "/^\\" Str)) Mtext (substr Mtext (+ 4 (strlen Str))) ) ) (1 (setq Text (strcat Text (substr Mtext 1 1)) Mtext (substr Mtext 2) ) ) ) ) ) Text ) |