LISP - move overlapping attribute of a block

LISP - move overlapping attribute of a block

dario_jukica
Contributor Contributor
337 Views
2 Replies
Message 1 of 3

LISP - move overlapping attribute of a block

dario_jukica
Contributor
Contributor

Hi,

 

I have blocks with attributes that overlap once placed.

Is it possible to make a LISP to move the attribute text to the nearest location where it won't overlap with other blocks or geometry with a leader, keeping the block's insertion point intact?

Sample attached.

 

Thank you.

 

Kind regards

 

0 Likes
Accepted solutions (1)
338 Views
2 Replies
Replies (2)
Message 2 of 3

EnM4st3r
Advocate
Advocate
0 Likes
Message 3 of 3

Kent1Cooper
Consultant
Consultant
Accepted solution

As much as I don't like to be discouraging, that seems like a near-impossible task for an AutoLisp routine.  I'm just trying to imagine how one would even start to go about it.  We should be able to come up with a bounding box for the Attribute, and test whether anything else overlaps that, but if so, where do we go from there?  Not even considering yet the connecting-leader question:

 

Say we first try repositioning the Attribute differently in relation to the Block's insertion point in some systematic way, looking for a place where it doesn't overlap anything -- reposition, test, if there's a conflict, reposition again, test again, etc.  We'll try the same distance from there, but in different directions -- let's try at 45° differences.  The positioning would be based on its insertion point, so if the white TEST here is the Block-definition location for the Attribute as in your sample, the lighter blue grips are at 45° changes in direction from the Block's insertion point, and the darker blue TESTs are the resulting locations of the Attribute:

Kent1Cooper_0-1688392052536.png

Most of those overlap the Block's own insertion Point, never mind any other Block's Attribute, or other drawn object(s).  Just from this possibility of an approach, I think at the very least the Attribute's justification should be MiddleCenter, so we would get trial positions more like this, with some hope [depending on the length of Attribute value content] of avoiding the risk of self-overlapping:

Kent1Cooper_1-1688392339530.png

Come to think of it, a routine could probably test new positions of a theoretical bounding box, without actually repositioning the Attribute and getting its bounding box in its new location to test for overlaps, in which case maybe the justification of the Attribute wouldn't need to matter.  But it would still need to check for stuff that overlaps the box excluding itself [such as in the location of the top-most TEST in the second image, which would be acceptable if clear of other things, even though it overlaps the original position].

 

But however that test operates, in your sample drawing, in very many cases none of those alternative positions would be clear of other things.  If not, should it try the same repositioning but farther out?  How much farther out?  How far away is too far?  At some distance away it should probably look at smaller increments in change of direction in hope of finding a clear spot.  Is there some point at which the routine should just give up?

 

If it finds a location that's clear of other stuff, should it just take it, even though it may not be the best solution?  Determining the "best" solution would be incomprehensibly complex, given that other nearby Blocks' Attributes may or may not already have been adjusted, and the results of making changes to multiple Blocks would affect each other.  The "best" solution might sometimes involve changing rotation angle of the Block as well as position of the Attribute:

Kent1Cooper_0-1688395017175.png

Etc., etc.

 

I have a feeling that even in a large drawing, you could reposition Attributes by hand [your brain is far better at seeing the possibilities in relation to each other than any AutoLisp routine] in far less time than it would take for someone to come up with a routine that could do it, if that's even possible.

Kent Cooper, AIA