Thanks Guys, I added the commands and fractions to RobertB's revisions and it works like a charm!
It contains 2 commands:
"UFD" to change horizontal fractions to diagonal
"UFH" to change diagonal fractions to horizontal
Below is the new code for everyone's use; I have tested it for Mtext in ModelSpace with Acad2010 only.
Code:
(defun c:UFD ()
(setq ztm (getvar "tilemode"))
(if (= ztm 0) ; tilemode 1=model space, 0=paper space
(command "tilemode" 1)
)
(FindReplaceAll "1/32" "1#32")
(FindReplaceAll "1/16" "1#16")
(FindReplaceAll "3/32" "3#32")
(FindReplaceAll "1/8" "1#8")
(FindReplaceAll "5/32" "5#32")
(FindReplaceAll "3/16" "3#16")
(FindReplaceAll "7/32" "7#32")
(FindReplaceAll "1/4" "1#4")
(FindReplaceAll "9/32" "9#32")
(FindReplaceAll "5/16" "5#16")
(FindReplaceAll "11/32" "11#32")
(FindReplaceAll "3/8" "3#8")
(FindReplaceAll "13/32" "13#32")
(FindReplaceAll "7/16" "7#16")
(FindReplaceAll "15/32" "15#32")
(FindReplaceAll "1/2" "1#2")
(FindReplaceAll "17/32" "17#32")
(FindReplaceAll "9/16" "9#16")
(FindReplaceAll "19/32" "19#32")
(FindReplaceAll "5/8" "5#8")
(FindReplaceAll "21/32" "21#32")
(FindReplaceAll "11/16" "11#16")
(FindReplaceAll "23/32" "23#32")
(FindReplaceAll "3/4" "3#4")
(FindReplaceAll "25/32" "25#32")
(FindReplaceAll "13/16" "13#16")
(FindReplaceAll "27/32" "27#32")
(FindReplaceAll "7/8" "7#8")
(FindReplaceAll "29/32" "29#32")
(FindReplaceAll "15/16" "15#16")
(FindReplaceAll "31/32" "31#32")
(if (= ztm 0) ; tilemode 1=model space, 0=paper space
(command "tilemode" 0)
)
(princ "\nChanged Horizontal Stacked dimensions to Diagonal Stacked.")
(princ)
);end defun C:UFD
;;
;;
;;Update Diagonal Fractions to Horizontal
;;
(defun c:UFH ()
(setq ztm (getvar "tilemode"))
(if (= ztm 0) ; tilemode 1=model space, 0=paper space
(command "tilemode" 1)
)
(FindReplaceAll "1#32" "1/32")
(FindReplaceAll "1#16" "1/16")
(FindReplaceAll "3#32" "3/32")
(FindReplaceAll "1#8" "1/8")
(FindReplaceAll "5#32" "5/32")
(FindReplaceAll "3#16" "3/16")
(FindReplaceAll "7#32" "7/32")
(FindReplaceAll "1#4" "1/4")
(FindReplaceAll "9#32" "9/32")
(FindReplaceAll "5#16" "5/16")
(FindReplaceAll "11#32" "11/32")
(FindReplaceAll "3#8" "3/8")
(FindReplaceAll "13#32" "13/32")
(FindReplaceAll "7#16" "7/16")
(FindReplaceAll "15#32" "15/32")
(FindReplaceAll "1#2" "1/2")
(FindReplaceAll "17#32" "17/32")
(FindReplaceAll "9#16" "9/16")
(FindReplaceAll "19#32" "19/32")
(FindReplaceAll "5#8" "5/8")
(FindReplaceAll "21#32" "21/32")
(FindReplaceAll "11#16" "11/16")
(FindReplaceAll "23#32" "23/32")
(FindReplaceAll "3#4" "3/4")
(FindReplaceAll "25#32" "25/32")
(FindReplaceAll "13#16" "13/16")
(FindReplaceAll "27#32" "27/32")
(FindReplaceAll "7#8" "7/8")
(FindReplaceAll "29#32" "29/32")
(FindReplaceAll "15#16" "15/16")
(FindReplaceAll "31#32" "31/32")
(if (= ztm 0) ; tilemode 1=model space, 0=paper space
(command "tilemode" 0)
)
(princ "\nChanged Diagonal Stacked dimensions to Horizontal Stacked.")
(princ)
);end defun C:UFH
;
;
;-------------------------------------------------------------------------------
; FindReplaceAll - Changes Text, Mtext, Dimensions and Attribute Block entities
; that have a Find$ string with a Replace$ string.
; Arguments: 2
; Find$ = Phrase string to find
; Replace$ = Phrase to replace it with
; Syntax: (FindReplaceAll "|" "1/4")
; Returns: Updates Text, Mtext, Dimension and Attribute Block entities
;-------------------------------------------------------------------------------
(defun FindReplaceAll (Find$ Replace$ / BlkEntList@ BlkEntName^ BlkEntType$ Cnt#
DimEntList@ DimEntName^ DimEntType$ EntList@ EntName^ EntType$ FindReplace
Mid$ Mid2$ NewText$ Num# SS& Text$)
(defun i:wcmatch (string pattern)
(wcmatch string (vl-string-subst "`#" "#" pattern)))
;-----------------------------------------------------------------------------
; FindReplace: - Returns Str$ with Find$ changed to Replace$
; Arguments: 3
; Str$ = Text string
; Find$ = Phrase string to find
; Replace$ = Phrase to replace Find$ with
; Returns: Returns Str$ with Find$ changed to Replace$
;-----------------------------------------------------------------------------
(defun FindReplace (Str$ Find$ Replace$ / Cnt# FindLen# Loop Mid$ NewStr$ ReplaceLen#)
(setq Loop t Cnt# 1 NewStr$ Str$ FindLen# (strlen Find$) ReplaceLen# (strlen Replace$))
(while Loop
(setq Mid$ (substr NewStr$ Cnt# FindLen#))
(if (= Mid$ Find$)
(setq NewStr$ (strcat (substr NewStr$ 1 (1- Cnt#)) Replace$ (substr NewStr$ (+ Cnt# FindLen#)))
Cnt# (+ Cnt# ReplaceLen#)
);setq
(setq Cnt# (1+ Cnt#))
);if
(if (= Mid$ "") (setq Loop nil))
);while
NewStr$
);defun FindReplace:
;-----------------------------------------------------------------------------
; Start of Main function
;-----------------------------------------------------------------------------
(if (and (= (type Find$) 'STR)(= (type Replace$) 'STR)(/= Find$ ""))
(progn
(if (setq SS& (ssget "x" (list '(-4 . "<AND")'(-4 . "<OR")'(0 . "TEXT")'(0 . "MTEXT")'(0 . "DIMENSION")'(0 . "INSERT")'(-4 . "OR>")(cons 410 (getvar "CTAB"))'(-4 . "AND>"))))
(progn
(setq Cnt# 0)
(repeat (sslength SS&)
(setq EntName^ (ssname SS& Cnt#)
EntList@ (entget EntName^)
EntType$ (cdr (assoc 0 EntList@))
Text$ (cdr (assoc 1 EntList@))
);setq
(if (= EntType$ "INSERT")
(if (assoc 66 EntList@)
(progn
(while (/= (cdr (assoc 0 EntList@)) "SEQEND")
(setq EntList@ (entget EntName^))
(if (= (cdr (assoc 0 EntList@)) "ATTRIB")
(progn
(setq Text$ (cdr (assoc 1 EntList@)))
(if (i:wcmatch Text$ (strcat "*" Find$ "*"))
(progn
(setq ReplaceWith$ (FindReplace Text$ Find$ Replace$))
(entmod (subst (cons 1 ReplaceWith$) (assoc 1 EntList@) EntList@))
(entupd EntName^)
);progn
);if
);progn
);if
(setq EntName^ (entnext EntName^))
);while
);progn
);if
(if (i:wcmatch Text$ (strcat "*" Find$ "*"))
(progn
(setq ReplaceWith$ (FindReplace Text$ Find$ Replace$))
(entmod (subst (cons 1 ReplaceWith$) (assoc 1 EntList@) EntList@))
(entupd EntName^)
);progn
);if
);if
(setq Cnt# (1+ Cnt#))
);repeat
);progn
);if
);progn
);if
(princ)
);defun FindReplaceAll