Add Space to Text and Mtext

Add Space to Text and Mtext

HarrySK
Enthusiast Enthusiast
879 Views
13 Replies
Message 1 of 14

Add Space to Text and Mtext

HarrySK
Enthusiast
Enthusiast

Hi All,

 

 I need to help for adding space between three digits of each numeric Text or Mtext.

 

thank in advance.

0 Likes
880 Views
13 Replies
Replies (13)
Message 2 of 14

ВeekeeCZ
Consultant
Consultant

Learn how to use MTEXT to have a frame with the mask.

0 Likes
Message 3 of 14

HarrySK
Enthusiast
Enthusiast

It is possible to add spaces to all mtexts and texts except grouped mtexts.

Because I have too many object and I know very little about Lisp code.

0 Likes
Message 4 of 14

ВeekeeCZ
Consultant
Consultant

Not sure what you mean by "grouped mtexts". 

 

But generally, I could do a routine that adds spaces to coordinates, but will not do the selection part. That should be up to the user and his workflow.

0 Likes
Message 5 of 14

Kent1Cooper
Consultant
Consultant

This will find all objects whose text content includes at least four numerical characters in a row, which seems like a reliable criterion for automating selection:

 

(ssget "_X" '((1 . "*####*")))

 

I would bet that there are already routines available for the Searching in this Forum and elsewhere, probably mostly to add commas every third character, but easily adaptable for spaces instead if there aren't any already written that way.

 

But questions arise:  I note the non-numerical letter at the beginning of some of your example objects.  It might be easy enough to work around that, but would there ever be more than that?  Suffix content beyond the end of the numerical part?  More wording before and/or after?  Multiple numerical portions within the same object?  Would the numerical part(s) you want processed always be separated from other content by a space?  Would there ever be more than three decimal places, and if so, should they also be space-separated into groups of three?  Etc.

Kent Cooper, AIA
0 Likes
Message 6 of 14

HarrySK
Enthusiast
Enthusiast

@Kent1Cooper

Before posting anything I check whether the Lisp I want is already available or not. I do this by searching a lot on Google. If I don't find it, I post it only and it would be wrong to claim that it will be available. There may be some similarities to some extent, but as I said, I know very little about Lisp.

 

For example, I have numbers only in two condition, I have shown them in the attached drawing.

0 Likes
Message 7 of 14

HarrySK
Enthusiast
Enthusiast

screenshot.png

 

@ВeekeeCZ

By selecting both text and wipeout objects together, it shows you as a group.

0 Likes
Message 8 of 14

ВeekeeCZ
Consultant
Consultant

You can use this routine.

https://www.cadforum.cz/en/qaID.asp?tip=4136

 

Use SRXTEXT2/Regular

 

For 2702450.631 use 

(.)(...)(.*)

to 

$1 $2 $3

 

for N 2674800

(...)(...)(...)

to 

$1 $2 $3

 

Your grouped MTEXT is more like grouped TEXT; it would be better to convert it to MTEXT first, remove the wipeout, and then do the space replacement... so the frame would be scaled too.

Message 9 of 14

Kent1Cooper
Consultant
Consultant

One that seems quite close is >this< TEST-CONV command by @CADaSchtroumpf.    In the first code window there, replace the 44 with 32 [to use spaces instead of commas] and see what you think.  It doesn't want the letter prefix, but probably that can be accommodated.  And for some reason in your sample drawing the one with decimal places got an extra space and 0 added at the end.  But it's a great start.

Kent Cooper, AIA
Message 10 of 14

HarrySK
Enthusiast
Enthusiast

@ВeekeeCZ
Thank you for telling me about lisp and how to use it. It is a bit difficult to do but it works perfect.

one again thank you

0 Likes
Message 11 of 14

HarrySK
Enthusiast
Enthusiast

@Kent1Cooper

Many many thanks I like it very much. It is easy to use but it does not work on all Text and Mtext. Example is the showing image in below.

 

HarrySK_1-1704387945912.png

 

0 Likes
Message 12 of 14

vladimir_michl
Advisor
Advisor

If you play with srxText2, you can try the following regex replacement for your job (replace the "," with a space):

 

Search: (\d)(?=(\d{3})+\b)

Replace: $1,

 

srxt.jpg

 

Looks like it fits the needs.

 

Vladimir Michl, www.arkance-systems.cz  -  www.cadforum.cz

 

Message 13 of 14

HarrySK
Enthusiast
Enthusiast

Thank you for Lisp, but it only works on some objects when manually selecting text.

0 Likes
Message 14 of 14

vladimir_michl
Advisor
Advisor

Some? You mean just some of different object types? Or some of the original texts? (that the "search for" part doesn't match?).

Can you send a sample DWG highlighting the texts which do not work?

 

Vladimir Michl, www.arkance-systems.cz  -  www.cadforum.cz

 

0 Likes