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
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.
Looks like what your looking for is "NESTING" ie place objects within a predefined rectang.
Google "Nesting Autocad lisp"
A quick way to check if there are shapes the are not touching other shapes is to:
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.
@leeminardi wrote:
....
- Convert all shapes to regions
- 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.
What im doing is using it for a tsp program thats why i need it connected somehow but what i ended up doing was writing a program that uses the start point and tries
to go to every pline if it cant add it to a selection set then go through the whole selection set that doesnt have a path to it vs that that does and find the 2 closest point and generate a line between the points from there do a new search
Can't find what you're looking for? Ask the community or share your knowledge.