Tool for laying groups/components flat for laser cutting?
-
Hi all, Quick question - I have a simple model of flat sheet components which I would like to 'lay flat' onto a sheet for laser cutting. That is, I'd like each group/component to rotate and be placed flat on the xy plane.
Does anyone know of a tool, ruby script, plugin, etc... that can help me expedite this process?
Or alternately, tho not as ideal, another software to bring it into?
Thanks!
-
Try out Unfold.rb or Flattery.rb ??
-
Tig, I don't think he wants to unfold the individual components, I think it's more like Eclate_Displace.
Imagine a cube whose faces were separate components, click the cube and all faces/components are moved to the Z axes and laid out on their flat surface.
It would be a very handy tool, albeit with restrictions as it may be difficult for it to understand which is the flat surface in more complex shapes.
Much like the "Produce a flattened copy" option in slicer.Correct me if I'm wrong and this can be done in unfold/flattery.
-
Hi
You can try this code, it is a WIP so works only for groups.It looks for a biggest face in group and rotate group so this face is up ( vector z+) and then it moves it to XY plane.
Select groups and run code:mod = Sketchup.active_model # Open model ent = mod.entities.to_a # All entities in model sel = mod.selection # Current selection groups=[] ent.each do |e| if e.is_a? Sketchup;;Group e.make_unique; groups<<e; end end big=[] groups.each do |g| #UI.messagebox g area=0 #UI.messagebox area grent=[] grent=g.entities.to_a name=g.name g.explode g = Sketchup.active_model.entities.add_group(grent) g.name= name grent.each do |e| if e.is_a? Sketchup;;Face if e.area>area #UI.messagebox e area =e.area; big<<e; end end end #UI.messagebox big.last #UI.messagebox big.last.normal if big.last.normal.cross([0,0,1]) != [0,0,0] g.transform! Geom;;Transformation.rotation(big.last.vertices[0],big.last.normal.cross([0,0,1]),big.last.normal.angle_between([0,0,1])) end name=g.name g.explode h = Sketchup.active_model.entities.add_group(grent) h.name= name vector=[] vector = Geom;;Vector3d.new 0,0,-h.transformation.to_a[14] #UI.messagebox vector h.transform! Geom;;Transformation.translation(vector) vector=[] end
Greets
Matt -
Box, yes thats more like what i am trying to do.
and
MattC, Thanks SO much for this script! It worked pretty well on the first run, although seems to skip some groups - i think i need to clean up my model a bit and try again.
Then, once i have all the groups flattened, do you know of a way to automate nesting them on a sheet? (like RhinoNest if you are familiar with that) Or at least move them apart on the XY plane, so that they are not intersecting?
Best,
Darrick(If nothing else, i can do this bit manually, as the script did most of the work of rotating down to the XY plane!)
-
Are yo really still on SU7?
I had PhlatBoyz 'phlat script' working on mac in SU7, but not in SU8...
it has all the requirements for producing the 'G'code for CAM directly from SU.
"SketchUcam" is the latest and greatest version, and is worth looking at [even if it doesn't run]
john
-
ive switched up to v8 but i can probably find and install 7 again just to test out that script.
i realized some of the pieces that werent flattening with MattC's script were actually 'components' so i just exploded them and grouped them, they worked ok. now just need to find a way to get all the pieces to 'spread' then 'nest'.
-
just try it on v8 first as it might be my setup that's at odds...
I'll try and see if I modified the script in a way that broke it for 8.
Nesting ain't easy... good luck in your search. and report back if you find something.
john
-
I have looked at nesting problem before, for a purpose of placing card model parts on A4 (A3) sheets.
But it is very complicated. I based my observations on bounding boxes (BB).
I can write supplement for this script that will place all groups from point (0, 0) along x axis with a distance of (n) between bounding boxes.
I can even code it so when first line of groups reaches specified border value, it will place next row above firs row (moved in y direction).
But this is definitely not an optimal nesting algorithm.Other problem is that bounding box of a group is not always optimally aligned with a part ( e.g. part is along diagonal of BB rectangle )
Solution is to rotate group so it spans along x or y axis, explode and regroup, new BB will match group better.
You can rotate groups manually, but if you have lots of them...
My idea was to use biggest face of every group (it is already used for facing up groups) ,and to find its main centroidal axis ( axis for which you get maximal and minimal moment of inertia β in other words points of a face are so close possible to one axis and so far possible from another), and angle between main axis and local X axis.
One piece of this puzzle is to get face vertices in order (clockwize of anticlockwise ). Does face.vertices works like that ? (Can't check it right now)
UPDATE Yes it works. face.vertices reports vertices in order.This is enough to calculate second moment of area and from there angle of rotation.As for working with components... I haven't used components yet in my scripts, so have no idea is it different than using groups.
Greets Matt
-
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
Advertisement