Auto stacking fractions
in Other
I need to have fractions auto-stack like AutoCAD does. Is it possible? Where can I find settings for this?
0
Comments
-
BricsCAD doesn't Autostack fractions as you type. You need to first type in what you want, select the text, then pick the stack button. Syntax for stacked text is:
- 1/2 for horizontal fractions.
- 1#2 for diagaonal fractions.
- 1^2 for stacking without a line. Useful for creating superscript and subscript text.
Once you have created a stacked fraction you can select it and by right clicking you can go to 'Stack Properties' where you can fine tune how your stacked text displays.
Regards,Jason Bourhill
0 -
Here is a lisp program that stacks MTEXT fractions. You can modify as you see fit...to include other items similar to fractions.
As you can see below it is limilted to 1/16" increments max. (but you could add more to the list)
You might want to remove the (princ N ) line and (princ.....SKIPPED)))) lines if you don't want all texts to print to console.
ddk
[code](defun c:STAKFRAC ()
(prompt "\nSelect Objects: (Select a window)")
(setq SS1 (ssget '((0 . "MTEXT"))))
(cond (SS1
(princ (sslength SS1))
(setq ALST
'(("15/16" "{\\H0.7x;\\A1;\\S15#16;}") ("13/16" "{\\H0.7x;\\A1;\\S13#16;}") ("11/16" "{\\H0.7x;\\A1;\\S11#16;}")
("9/16" "{\\H0.7x;\\A1;\\S9#16;}") ("7/16" "{\\H0.7x;\\A1;\\S7#16;}") ("5/16" "{\\H0.7x;\\A1;\\S5#16;}")
("3/16" "{\\H0.7x;\\A1;\\S3#16;}") ("1/16" "{\\H0.7x;\\A1;\\S1#16;}") ("7/8" "{\\H0.7x;\\A1;\\S7#8;}")
("5/8" "{\\H0.7x;\\A1;\\S5#8;}") ("3/8" "{\\H0.7x;\\A1;\\S3#8;}") ("1/8" "{\\H0.7x;\\A1;\\S1#8;}")
("3/4" "{\\H0.7x;\\A1;\\S3#4;}") ("1/4" "{\\H0.7x;\\A1;\\S1#4;}") ("1/2" "{\\H0.7x;\\A1;\\S1#2;}")))
(setq N 0)
(princ " Done")
(repeat (sslength SS1) ;Walk through text
(princ N)
(setq E1 (ssname SS1 N)
ET (cdr (assoc 0 (entget E1))))
(cond ((= ET "MTEXT") ;Check again
(cond ((assoc 3 (entget E1)) ; Toss paragraph
(princ " Mtext Paragraph Skipped\n"))
((and (assoc 1 (entget E1)) ;Has text string
(= (cdr (assoc 67 (entget E1))) 0)) ;And is in Model Space
(setq TXT (strcase (cdr (assoc 1 (entget E1)))))
(foreach TX ALST ;Walk through fraction list
(cond ((wcmatch (strcase TXT)(strcase (strcat "*" (car TX) "*"))) ;fraction found
(princ (strcat " " (cdr (assoc 1 (entget E1))) " Found\n"))
(command "ZOOM" "C" (cdr (assoc 10 (entget E1))) 20.0)
(redraw E1 3)
(prompt "\n(E)dit (N)ext")
(setq INP (grread) IN (car INP))
(if (= IN 2)(setq YN (strcase (chr (cadr INP)))))
(cond ((= YN "E")
(setq STRL (strlen (car TX)) ;String Length of fraction
N0 (vl-string-search (car TX) TXT) ;Location of fraction
STR1 (substr TXT 1 N0)) ;Text Before
(if (= (substr STR1 N0) " ")(setq STR1 (substr STR1 1 (1- N0)))) ;Strip trailing blank
(setq STR2 (substr TXT (+ N0 STRL 1)) ;Text After
STR1 (strcat STR1 (cadr TX) STR2) ;replacement String
EL (entget E1)
EL (subst (cons 1 STR1)(assoc 1 EL) EL)) ;subtitute in entity
(entmod EL))))))
(princ (strcat " " (cdr (assoc 1 (entget E1))) " Skipped\n"))))) ;Mtext no fractions
(t
(princ (strcat " " (cdr (assoc 1 (entget E1))) " Odd Text Skipped\n")))) ; Wierd stuff
(setq N (1+ N))))
(t
(princ " No Text Found")))
(princ "\nDone")(princ))
[/code]0
This discussion has been closed.