Hi
Here is another WIP code this time wrapped up as a plugin. Still it works only for groups.
Running: Select entities first, then use menu Plugins/SPP to execute plugin, click with a left mouse button on a screen. Observe status balk messages.
How it works:
Plugin works in 4 steps.
It will search for all groups in a selection and make every group unique
In every group it searches for a biggest face, and then rotates whole group so normal vector of biggest face is pointed up (0,0,1)
Then the angle between X axis and main centroidal axis of this face is found, and group is rotated one more time, to match orientation along X axis.
Last step is placing oriented groups along Y axis, with a separation between groups ( bounding boxes ) of 1 inch. ( to change it look for separation=1 in a script and change it there, I will code another way to do it later).
Calculation based on :
http://en.wikipedia.org/wiki/Polygon_area#Area_and_centroid
http://en.wikipedia.org/wiki/Second_moment_of_area#Any_cross_section_defined_as_polygon
Therefore it works nicely for a faces without inner holes. For a faces with holes it gives a slight incorrect result in step 3.
This plugin is a part of a bigger toolset that I am making to use Sketchup for making paper models ( SPP stands for Sketchup-Paper-Planes), more will surface in a near future.
Greets
Matt
Groups to XY plane