Community
Visual LISP, AutoLISP and General Customization
cancel
Showing results for
Show  only  | Search instead for
Did you mean:

## Make all Objects Touch

5 REPLIES 5
Message 1 of 6
408 Views, 5 Replies

## Make all Objects Touch

What im pretty much doing is trying to come up with a code that will make all my shapes touch within the boundaries of

(setq p1 (list (* 120 25.4) (* 72 25.4)))
(setq p2 (list (* (+ (/ (car p1) 25.4) 120.01) 25.4) (* (+ (/ (cadr p1) 25.4) 72.01) 25.4)))

If you see my dwg you will see that the top left has a gap. Can someone help write a code that i can run that will auto check all shapes ( Rectangles, Trapezoids, Circles ) that there is atleat one touching point and its within the boundaries of what is provided i dont want it shifting outside of p1 and p2

5 REPLIES 5
Message 2 of 6

I'm not seeing an easy way to do that, but first, a major question:

How would a routine know what to change to make them all touch?  In your example, the upper left-ish corner of the trapezoid could be moved left to touch the rectangle [changing the slope of the sloped edge, or the lower right corner of the rectangle could be moved right to touch the trapezoid [making the right edge of the rectangle not vertical], or the entire right edge of the rectangle could be moved the same way [lengthening the rectangle], or the entire rectangle could be moved right or down, or either the lower right corner of the rectangle [making the bottom edge not horizontal] or the entire bottom edge of the rectangle [increasing the height] could be moved downward until the lower right corner hits the sloped edge of the trapezoid, or either that corner of the trapezoid [making its top edge not horizontal] or its entire top edge moved up until its sloped edge touches the rectangle [changing the slope of the sloped edge in either case], or....  [In the attached, the green things are the initial condition, and the dashed yellow some of the possible solutions.]

And that's just this configuration.  I can imagine different starting configurations could include yet more possible solutions.

Kent Cooper, AIA
Message 3 of 6

Looks like what your looking for is "NESTING" ie place objects within a predefined rectang.

Message 4 of 6

A quick way to check if there are shapes the are not touching other shapes is to:

1. Convert all shapes to regions
2. Use UNION to make one object from all the shapes.

Union will create a single shape altough some parts may not touch but will create closed shapes.  At this point just give the hatch command and move your cursor over the shape to see where the gaps are.

lee.minardi
Message 5 of 6

@leeminardi wrote:

....

1. Convert all shapes to regions
2. Use UNION to make one object from all the shapes.

.... give the hatch command and move your cursor over the shape to see where the gaps are.

Even after I move the rectangle over so that it touches the trapezoid at the corner, the same happens.  No gap, but Hatch only "sees" the same smaller area when hovering in it, not the entire Unioned Region.  For that test to work as I think you intend, there needs to be some overlap of edges, not just touching at a corner, so that space "flows" through between the parts.  If touching at a corner satisfies the OP, this would not be a reliable way to find that something doesn't touch.

Kent Cooper, AIA
Message 6 of 6