Text Spacing Lisp Routine

Text Spacing Lisp Routine

eoconnor95662
Enthusiast Enthusiast
4,308 Views
9 Replies
Message 1 of 10

Text Spacing Lisp Routine

eoconnor95662
Enthusiast
Enthusiast

I am looking for a lisp routine that will take aligned text and "condense" a series of MTEXTs to be equal spacing between them.

 

I would like to take a selection of MTEXTs and have it space each MTEXT box a reasonable, uniform distance apart (.8?). I have found code that will set MTEXT a distance away from a line but results in all the text being stacked, and a text spacing routine that looks promising, but doesn't work for me, which I have attached below.

 

Please let me know if you need further clarification.

0 Likes
4,309 Views
9 Replies
Replies (9)
Message 2 of 10

Kent1Cooper
Consultant
Consultant

This may be slightly different from what you're asking, but you may be able to use OneMtext.lsp with its 1MT2 command, available >here<.  It assembles both Text and Mtext objects into [as the file name and the 1 at the beginning of the command name imply] One Mtext object.  It contains other commands, also -- the 2 at the end of the command name I'm suggesting means it puts 2 Enters between the content of each selected object, so that there's an empty line between what came from each original object.  It uses the Mtext-box width of the first selected one, so later-selected ones can end up with their line-break locations different from their original configuration.

 

Differences from your description:  It doesn't space the objects as separate ones, but combines them into one, which is how it gets them aligned.  And you don't get to specify the "reasonable, uniform distance apart," but it's the result of the line spacing of the font involved, and whether the first Mtext object is set for "At least" or "Exactly" line spacing.  I hope that ends up being "reasonable" enough for you.

 

Unlike the TXT2MTXT command, it accepts both Text and already-Mtext objects, and the order they combine in depends on the order of selection, not their relative original positions.

 

[Other commands defined in the file:  The 1MT1 command puts 1 Enter between, that is, starts a new paragraph for the content of each selected object, but without an empty line between.  The 1MT0 command puts just a space between, rather than any Enter(s), so that the combined content "flows" through in one continuous paragraph.]

 

Here's what 1MT2 does:

1MT2.PNG

Kent Cooper, AIA
Message 3 of 10

eoconnor95662
Enthusiast
Enthusiast

This will most likely fit the bill, however could you make it so I can drag and select MTEXT boxes rather than individually click on for desired merging? I have a rather large data set.

0 Likes
Message 4 of 10

Kent1Cooper
Consultant
Consultant

@eoconnor95662 wrote:

This will most likely fit the bill, however could you make it so I can drag and select MTEXT boxes rather than individually click on for desired merging? I have a rather large data set.


 

I made that routine for the purpose of combining a lot of specification-like notes that were separate Mtext and Text objects in multiple columns of them, and I needed something that not only accepted Mtext but also did not  work positionally as TXT2MTXT does, because of this kind of [simplified example] situation:

1MT1vsTXT2MTXT.PNG

That TXT2MTXT result in the middle [no matter how the Text objects are selected] has a text-string content [without the word-wrapping] of:

"TEXT 1 TEXT 5 TEXT 2 TEXT 6 TEXT 3 TEXT 7 TEXT 4 TEXT 8"

which is completely not what I needed.  It's the columns situation that causes it, since it's position-based.  I needed one object with the string contents in non-positionally-based order, as on the right, which is why it's set up to use order of selection.

 

It could be altered to use some other order, but figuring out how to work that could be a challenge -- what kind(s) of circumstances would you have?  Would you ever have anything like my multiple columns?  If not, would you always want things in positional order, but just straightened out / spaced this way?  [If they're sort of in the ballpart, they could be sorted by, for example, the Y coordinates of their insertion points, but would sorting by X coordinates ever be more appropriate?]  How far out of alignment might things be?  If you pick things by window, the order in the selection is related to drawing order, which may have no relation to the order you want the results in.  Are you willing to at least be restricted to Fence-based  selection, so that the result will have an order that you can control, but without your needing to pick things one at a time?  If so, you would need to be careful to make your selection Fence cross some character  in each object, and not pass through a space between, where it won't find that object.

Kent Cooper, AIA
0 Likes
Message 5 of 10

eoconnor95662
Enthusiast
Enthusiast

I basically have a large column set of Mtexts that I copy and paste what I want from (individual mtexts). This data needs to be scrunched up into another column of Mtexts (order does matter and needs to be preserved). This is why converting to 1 large Mtext will also work...they are already aligned to a side (X-position) but merely need to be condensed (Y-position). It will always be just 1 large column. Alignment spacing should be just far apart enough to read the separate Mtexts.

 

They are ordered from top to bottom and need to be kept as such.

Also there is blocks referenced by the text right next to it, I assume moving those also are more difficult so I was just going to move those manually, but figured I'd add that as a caveat just in case you had any ideas or was feeling ambitious 🙂

0 Likes
Message 6 of 10

Kent1Cooper
Consultant
Consultant

@eoconnor95662 wrote:

...they are already aligned to a side (X-position) but merely need to be condensed (Y-position). It will always be just 1 large column. Alignment spacing should be just far apart enough to read the separate Mtexts.

 

They are ordered from top to bottom and need to be kept as such.

Also there is blocks referenced by the text right next to it, I assume moving those also are more difficult ....


 

That would be possible in two general ways:  1) combination into one Mtext with blank lines between, as in the 1MT... commands, and  2) positioning of each independently based on its bounding box, with whatever size space between them you like [such as, for example, 1-1/2 times the text height].

 

Establishing the order of them is the challenge.  If you don't mind being restricted to Fence  selection running down the column, the order in such a selection set follows the Fence, which makes it fairly easy.  If you want more flexibility in selection [windowing, lassoing, individual picks, removing/adding, etc.], a routine could determine relative position from sorting by the Y coordinates of insertion points.

 

If there's a single  Block associated with each Mtext object, and no Mtext object does not  have a Block associated with it, I can sort of imagine a way to include positioning of those.  It would mean [as I'm imagining doing it] keeping the Mtext objects separate.  And it would depend in part on the width of the Mtext objects.  Would those vary?  I ask because the bounding box of Mtext, that would used to determine where in the X direction to put the Blocks, is the width of the Mtext "envelope" box, not the width of the actual content.  So if the "envelope" of any may be a lot wider than what's in them, and a lot wider than the others, the Blocks could land farther away from the column of Mtext than you want.

Kent Cooper, AIA
Message 7 of 10

eoconnor95662
Enthusiast
Enthusiast

They do not all have blocks associated with them.

 

I don't mind being restricted to Fence  selection running down the column. Would you be able to whip something up for me? You can ignore the bit about blocks, there really isn't that many (compared to text)

 

Thanks for helping me figure out what is needed!

0 Likes
Message 8 of 10

eoconnor95662
Enthusiast
Enthusiast

Can anyone add an explode command to the end of this LISP routine?

0 Likes
Message 9 of 10

Anonymous
Not applicable

Hi,

Can you please help me with the lisp routine as per my requirement? please refer below for an explanation. I have to do this process for 200 drawings and doing manually takes a lot of time. please help. I have also attached the screenshot for clarity. hoping to get a quick response from you.

 

Explanation:
1. The Table was already existing and exploded.
2. I have added a text in the 2nd column by find and replace.
3. some rows have the proper height to accommodate added text and some rows don't have which is overlapping with other row text.

 

Lisp Needed:
1. The Lisp should take the reference of the correct row by asking for selection.
2. After the selection of the correct row, the lisp should now ask to select the rows to be corrected.
3. Based on the input received by selecting the correct row, the lisp should apply the properties of the correct row to the rows which need to be corrected.

 

Hope I have explained my requirement in an understandable way.

 

Thanks in Advance

Vivek

 

 

 

 

0 Likes
Message 10 of 10

Sea-Haven
Mentor
Mentor

Dont explode the table you can read every cell in a column and get strlen which is how many characters then can add a fuzz factor and reset the column width.

 

(vla-Setcolumnwidth Objtable 2 100) ; column 2 which is 3rd 1st is 0

 

0 Likes