Spaces after Stack fractions

Spaces after Stack fractions

dnelson
Participant Participant
534 Views
9 Replies
Message 1 of 10

Spaces after Stack fractions

dnelson
Participant
Participant

I am looking for script that will remove spaces after a stacked fraction in mtext.  Autocad only allows certain symbol to invoke a stacked fraction.  Where this becomes an issue is when calling out steel shapes.  Per the AISC they don't use " marks to so to invoke stacked fraction you have to insert an extra space after the fraction.  What I would like to do is remove those extra space after the fact through a script.  I figured since we are using a reduced size stacked fraction one could search for the end } for the format and remove the space after that.  Although I am not lisp expert so maybe there is a better way to achieve this? 

 

Screenshot 2022-11-07 101924.png

0 Likes
535 Views
9 Replies
Replies (9)
Message 2 of 10

Kent1Cooper
Consultant
Consultant

The } end-of-format character would also exist at the ends of other kinds of formatting [color, for example] where you may not want a following space removed.  If that kind of thing would never be part of your Mtext usage, it may not be hard to code such a thing.  If it might, searching for \S in the text content and removing the space after the next } might work, but there could be complications if formattings overlap.

Kent Cooper, AIA
0 Likes
Message 3 of 10

Sea-Haven
Mentor
Mentor

Looking for " X" and replace with "X" may be better , try this.

 

 

(defun C:wow ( / )
(setq ent (entget (car (entsel "\nPick text "))))
(setq str (cdr (assoc 1 ent)))
(setq str (vl-string-subst "X" " X" str))
(setq str (vl-string-subst "X" " X" str))
(entmod (subst (cons 1 str) (assoc 1 ent) ent))
(princ)
)
(c:wow)

 

 

 

0 Likes
Message 4 of 10

dnelson
Participant
Participant
Thanks. I will give it a shot. I will also have to deconstruct your script to see how did it, as I am just learning. I have written quite a few things in Python but now trying to wrap my head (and syntax) around lisp.
0 Likes
Message 5 of 10

Sea-Haven
Mentor
Mentor
(defun C:wow ( / ent str ) ; defun name C: implies command line input is ok
(setq ent (entget (car (entsel "\nPick text ")))) ; select text and open up all the properties making the text
(setq str (cdr (assoc 1 ent))) ; dxf code 1 for text is the textstring (1 . "Textstring")
(setq str (vl-string-subst "X" " X" str)) ; swap spaceX for just X
(setq str (vl-string-subst "X" " X" str))
(entmod (subst (cons 1 str) (assoc 1 ent) ent)) ; modify the text object changing dxf property 1.
(princ)
)
(c:wow)

 

One of the things is to do a little bit of homework about DXF codes. It is the basis of the Autocad database. An object has properties which have a certain dxf code, a common one is 8 which is layer, 10 is often a XYZ point.

0 Likes
Message 6 of 10

ronjonp
Mentor
Mentor

I could create that text without the spaces?

ronjonp_0-1668026893631.png

 

0 Likes
Message 7 of 10

dnelson
Participant
Participant

Humm.  How did you do that?  If I type 4, space, 1, forward slash,2 it doesn't stack until I enter in one of the invoking characters described here.   If I enter the x after the 2 it then screws up the auto stacking.  

 

To Work With Stacked Text | AutoCAD | Autodesk Knowledge Network

0 Likes
Message 8 of 10

pendean
Community Legend
Community Legend

My test, no spaces either

pendean_0-1668030492146.png

 

0 Likes
Message 9 of 10

dnelson
Participant
Participant

So that looks just like my settings. 

 

What did you specifically type to get the autostacking to work, without putting a space in after the lower fraction number?  

0 Likes
Message 10 of 10

Sea-Haven
Mentor
Mentor

Tested with Bricscad and you type 41/2 then highlite 1/2 pick fraction icon all done. No spaces. Also Autocad highlite then b/a

 

SeaHaven_0-1668043542313.png

 

0 Likes