Fit table cell text in one line

Fit table cell text in one line

Anonymous
Not applicable
3,156 Views
3 Replies
Message 1 of 4

Fit table cell text in one line

Anonymous
Not applicable

Hello all.

 

As the title suggests, I need help to fit the text cells of an AutoCad table in one line. I've read through Autodesk documentation and I find it a nightmare, I'm just going round in circles. I've looked up the two following options to no avail (SetAutoScale and SetAutoScale2). The first one is self-explanatory whereas the second one is unclear as far the nContent parameter (what is it exactly? It's a Long so being the actual content of the cell would make no sense).

 

Both methods may not be what I'm after, but do you have any ideas? I've also tried to use Stretch but it's not available in VBA Autocad to my surprise (maybe it's been named differently in VBA?). I want to fit all of the cells in the table but would it be possible apply it to cells in the data range, for instance, and not those in the headers?

 

Thank you.

 

object.SetAutoScale row, col, bValue

 

object.SetAutoScale2 nRow, nCol, nContent, bAutoFit
0 Likes
Accepted solutions (1)
3,157 Views
3 Replies
Replies (3)
Message 2 of 4

grobnik
Collaborator
Collaborator

Hi @Anonymous ,

I cannot answer directly to your question but could be used a method to fix the cell width based upon bounding text box dimensions.

I know it's an empiric method but in my opinion should work.

You should make a scan of all text content, calculating the width based upon bounding box, and fix the column width with max value result, before populating the cell, and fix manually the column width.

I don't know what's happen if the cell it's linked for example with and excel file where the option of text wrap it's disabled.

I'm trying to investigate, or may be some forum expert could help you more before.

Bye

0 Likes
Message 3 of 4

grobnik
Collaborator
Collaborator
Accepted solution

Hi @Anonymous , @ambrosl it was a long time ago 2018, and I had the same issue, see my post https://forums.autodesk.com/t5/vba/table-setautoscale-amp-setautoscale2/td-p/7715509

and the answer of an expert @ambrosl was the same of that I gave you to calculate the width of longest text and fix later the width.

See also the code attached to that post, could help you.

I tried also with a simple table in a drawing and the effect was the same the column width still remain the same and does not fit to the text plus setting cell margin.

Probably something has been updated since 2018 to now, but I'm missing something.

 

Bye 

Message 4 of 4

Anonymous
Not applicable

Good morning grobnik,

 

Thanks a lot for your reply and the time you have put into it, the whole situation was driving me nuts. I'm glad that I asked you because I can see we went through the same struggles. I'm also glad that the AutoDesk expert admitted that the documentation needs improving as it's completely unclear.

 

I'm going to accept your answer as it doesn't seem to be any other solution for the time being.