The text inside the block moves to the boundary?

The text inside the block moves to the boundary?

1127204185
Advocate Advocate
2,598 Views
24 Replies
Message 1 of 25

The text inside the block moves to the boundary?

1127204185
Advocate
Advocate

The text inside the block moves to the boundary?test22.png

0 Likes
2,599 Views
24 Replies
Replies (24)
Message 2 of 25

1127204185
Advocate
Advocate
 sample:test22.dwg
 
Marko, can you help me? Thank you!
 
 
0 Likes
Message 3 of 25

Kent1Cooper
Consultant
Consultant

I don't like to sound discouraging, but that seems like a near-impossible task to automate.

 

The only way I can even start to think about how to do it would be to have a routine run an 'IntersectWith function on each piece of Text in comparison with each of the Block's perimeter Polylines, to find out whether it overlaps any of them.  Where it does, presumably it would have to compare the intersection locations with the Block's overall extents to figure out which way to Move the Text.  It would Move it a little, try again, and repeat until it no longer intersects with that boundary object.

 

But several complications arise:

 

In the case of the "1" at the top-most "peak" of the ST2 Block, the X direction that would get the Text closer in its X coordinate to the X coordinate of the Block's middle would be leftward, so it would presumably Move it in the wrong direction, and end up with it outside the boundary when it finally doesn't intersect that edge any more.

 

If it can somehow [and I don't have any idea how yet] be made to figure out a way to go in the right direction, in similar situations [not quite true here] it could easily Move a piece of Text until it clears the one edge, but then it could intersect another edge.  So it would have to compare the Text to every edge again, and presumably Move it [in this case] downward a little [closer to the Block midpoint's Y coordinate] and go through the whole exercise again, hoping that eventually it will get it clear of one edge without crossing another one.

 

Then there's the fact that the IntersectWith method works with the rectangular bounding box of the Text.  Again, in the case of that "1", because of the angle of the boundary where it intersects it, if a routine Moves it to the right, it would have to Move it farther to get no intersection than is necessary for the character itself to clear the boundary.  So it could end up Moving it more than is really required, and causing an intersection with another boundary object unnecessarily.

 

And what if a Text object is originally fully outside the boundary, and doesn't intersect any edge?  How would a routine know it had to be Moved at all, let alone in what direction?  That might be possible if the boundary of each Block was one Polyline [there are routines around here to determine whether or not a location is inside a closed Polyline], but when they're separate pieces like this, some of them concave and some convex in relation to the overall shape, it's really hard to imagine how a determination could be made.

 

I'm stumped....  I think the time it would take you go do it manually, even on a pretty large number of such Blocks, would be far less than the time it would take someone to come up with code to do it automatically.

Kent Cooper, AIA
0 Likes
Message 4 of 25

1127204185
Advocate
Advocate
Can that friend help write a lisp?
0 Likes
Message 5 of 25

john.uhden
Mentor
Mentor

I don't get it.  You seem to be saying that the text moves (itself?) to the boundary, but the graphic shows it in the middle of the boundary.

Whatever the case, maybe you want to make the text an attribute of the block, middle justified, so that it stays relatively where you want it with respect to the block.

 

I am sorry, but I have noticed over the years that many of us get ourselves into "bad" drafting and then look for a custom program to correct our mistakes.  Often, thinking ahead precludes such problems.

John F. Uhden

0 Likes
Message 6 of 25

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

I don't get it.  You seem to be saying that the text moves (itself?) to the boundary, but the graphic shows it in the middle of the boundary.

Whatever the case, maybe you want to make the text an attribute of the block, middle justified, so that it stays relatively where you want it with respect to the block.

....


It's not the obvious larger ones in the middles, but the tiny ones in the corners.

 

In some cases, just changing their justifications from Left to Middle might do it, but  A) that wouldn't work for all of them [e.g. the lower right corner one of ST1, which is currently inside but would then hit a boundary], and  B) it would depend on the number of characters in each.

Kent Cooper, AIA
0 Likes
Message 7 of 25

Kent1Cooper
Consultant
Consultant

@1127204185 wrote:
Can that friend help write a lisp?

If by "that friend" you mean me, I still feel the same as what I said in the last paragraph of my first Reply [with correction -- "...the time it would take you to do it manually..."].

Kent Cooper, AIA
0 Likes
Message 8 of 25

devitg
Advisor
Advisor

1127204185  , you work on a  ACAD /LT , no lisp available  

 

 

Opening an AutoCAD 2004/LT 2004  format file.
Substituting [@extfont2.shx] for [romans.shx].
Regenerating model.
0 Likes
Message 9 of 25

Scottu2
Advocate
Advocate

Perhaps the method would be...

 

First to find the corners (endpoint of the polyline) and the center of the object (average X's and Y's).

Then change the text to middle and move them by insert point to nearest end polyline end point within some +/- tolerance.

Then move the text 2 or 3 times its text height toward the center point.

 

0 Likes
Message 10 of 25

Kent1Cooper
Consultant
Consultant

@Scottu2 wrote:

Perhaps the method would be...

 

First to find the corners (endpoint of the polyline) and the center of the object (average X's and Y's).

Then change the text to middle and move them by insert point to nearest end polyline end point within some +/- tolerance.

Then move the text 2 or 3 times its text height toward the center point.


I suspect the viability of that would depend a lot on the actual shape of the boundary.  It doesn't look to me as though 3x the height would Move them far enough at the top or bottom ends of the ST2 shape in the original image.  And at the left corner of that one, basing the Move displacement on the Text height when the direction would be essentially horizontal might succeed for short strings, but if the string lengths vary, could well not Move longer ones far enough to clear.

 

So many variant possibilities -- it seems unlikely that a universal solution is possible.

 

But I'm curious to know whether they are in fact using Acad LT, if @devitg's command-line excerpt really means the drawing was done in that.  If so, there's no point in thinking about an AutoLisp approach.  But @1127204185 did ask for that in Post 4, which I hope means they would be able to use such a routine.

Kent Cooper, AIA
0 Likes
Message 11 of 25

devitg
Advisor
Advisor

Or maybe , @1127204185  did not notice about  it. 

 

It is not the first time I see a post asking for a lisp , and the OP  run  LT . 

 

So, why not? 

 

 

0 Likes
Message 12 of 25

1127204185
Advocate
Advocate

help

0 Likes
Message 13 of 25

devitg
Advisor
Advisor

Dear OP, please take it  as the  ACAD-LISP first law.

 

Lisp "CAN NOT RUN ON ACAD LT"

 

So it can not be do a LISP to run at ACAD-LT . 

 

 

0 Likes
Message 14 of 25

1127204185
Advocate
Advocate

why

0 Likes
Message 15 of 25

devitg
Advisor
Advisor

Did you ever try to run a lisp on LT?

 

And you ask why , just simple,  it is so , as LT is a cheap ACAD , it lost the Lisp feature. 

 

 

Just to test . type VLIDE at the acad command line 

 

or copy and paste it to acad command line 

 

(alert "I can run LISP")

 

Sorry.

 

 

 

 

0 Likes
Message 16 of 25

Kent1Cooper
Consultant
Consultant

@1127204185 wrote:

why


Because LT is for "LighT," and a light-weight version of any program is going to have fewer capabilities than the full version -- that's why it's less expensive.  One of those differences in this case is that AutoLisp capability is simply not included in LT -- you need to have full AutoCAD, or one of the overlay programs built on full AutoCAD, to get it.

Kent Cooper, AIA
0 Likes
Message 17 of 25

roland.r71
Collaborator
Collaborator

@devitg wrote:

1127204185  , you work on a  ACAD /LT , no lisp available  

 

 

Opening an AutoCAD 2004/LT 2004  format file.
Substituting [@extfont2.shx] for [romans.shx].
Regenerating model.

You are mistaken.

 

What it says is: The file format is valid for BOTH AutoCAD 2004 AND AutoCAD Lite 2004.

 

Which doesn't mean he actually uses the LT.

 

Just click 'save as...' & check the file formats, to see for yourself.

0 Likes
Message 18 of 25

Kent1Cooper
Consultant
Consultant

@roland.r71 wrote:
.... 
Which doesn't mean he actually uses the LT.
....

That was my uncertainty in the last paragraph of Post 10.  We haven't heard specifically from the OP that they do use LT, but I assume so from Posts 12 & 14.

Kent Cooper, AIA
0 Likes
Message 19 of 25

pbejse
Mentor
Mentor

@Kent1Cooper wrote:
 -- "...the time it would take you to do it manually..."].

Same here.

 

It makes me wonder why the need for a program and the "TEXT" is not even an attribute that would change from time to time. Maybe there's more to this than what the OP is telling us.

 

 

0 Likes
Message 20 of 25

roland.r71
Collaborator
Collaborator

@Kent1Cooper wrote:

@roland.r71 wrote:
.... 
Which doesn't mean he actually uses the LT.
....

That was my uncertainty in the last paragraph of Post 10.  We haven't heard specifically from the OP that they do use LT, but I assume so from Posts 12 & 14.


Those made me asume he's not aware of any variation in acad flavours & which flavour he's using 😉

 

He could be using LT 2004, could be full fledged 2017. The file format won't tell...

 

The file itself DOES contain the info.

 

18.2.51.0.0

Autodesk DWG

Last Saved By: AutoCAD Build F.51.0.0 (x64)

Registry version 18'18.2

 

His installation dir:

C:\program files\autodesk\2012\autocad 2012

 

So, i'd say he uses AutoCAD 2012 (Full 64 bit version)

 

edit:

...and he's definately Chinese 😛

0 Likes