First, sorry for my English.
I work with physical model, I’m not a programmer, but with a lot of struggle I managed to create an extension that has helped me a lot in my work.
I have a script to plan the parts, it works very well, but I would like it to create a classification by layer, like a space of 2mm of parts of the same layer, and a space of 100mm of parts in layers differences, something similar to what happens with the ABF extension.
def self.planificar
mod = Sketchup.active_model
ent = mod.active_entities
sel = mod.selection
SKETCHUP_CONSOLE.clear
org = Geom::Point3d.new(); spc = 2.mm
cdn = ent.grep(Sketchup::ComponentInstance).map{|ci|ci.definition.name}.uniq.sort
cdn.each{|n|
cis = ent.grep(Sketchup::ComponentInstance).each{|ci|
next unless ci.definition.name==n
ci.transform! ci.transformation.inverse
ci.transform! Geom::Transformation.translation(org-ci.transformation.origin)
if ci.bounds.width>ci.bounds.height
ci.transform! Geom::Transformation.translation(org-ci.bounds.corner(2))
ci.transform! Geom::Transformation.rotation(org,Z_AXIS,90.degrees)
end
if ci.bounds.depth>ci.bounds.width && ci.bounds.depth>ci.bounds.height
ci.transform! Geom::Transformation.rotation(org,X_AXIS,90.degrees)
end
if ci.bounds.min.y < org.y
ci.transform! Geom::Transformation.rotation(org,X_AXIS,180.degrees)
ci.transform! Geom::Transformation.translation(org-ci.bounds.corner(0))
end
org.offset!([ci.bounds.width+spc,0,0])
}
}
end