Thanks sdmitch, that's a much easier way to do that!
I should have asked what I really wanted to know instead of providing a simplified example.
FYI this is all in the context of me wanting to make some things to 3d print.
Two questions really,
- In the following code, is there a way to automatically remove the 3d text after doing the intersect so that I'm left with a solid rectangle that has the letters "Bob" punched through it?
model = Sketchup.active_model
entities = model.entities
entities.clear!
#Create a group to collect all entities for base cube
basegroup=entities.add_group
basegroupentities=basegroup.entities
p1 = Geom;;Point3d.new(0, 0, 0)
p2 = Geom;;Point3d.new(7, 0, 0)
p3 = Geom;;Point3d.new(7, 4, 0)
p4 = Geom;;Point3d.new(0, 4, 0)
points = [p1,p2,p3,p4]
base = basegroupentities.add_face points
base.reverse! if base.normal.z < 0
base.pushpull 1
base_trans=basegroup.transformation
cutgroup = entities.add_group()
cutgroup.entities.add_3d_text('Bob', TextAlignCenter, "Arial", true, false, 3.0, 0.0, 0.0, true, 1)
transform = Geom;;Transformation.new(Geom;;Point3d.new(0.5,0.5,0))
entities.transform_entities(transform, cutgroup)
cut_trans = Geom;;Transformation.new(Geom;;Point3d.new(0,0,0))
intersections = Sketchup.active_model.entities.intersect_with true, cut_trans, basegroup.entities, base_trans , true, basegroup.entities.to_a
cutgroup.explode
basegroup.explode
model.active_view.zoom_extents
- I feel like these two are related. In this example I get close to what I want but the new faces created by the intersect_with remain on the cylinder, and when I delete them by hand I'm left without any faces inside the cylinder, which I think means the cylinder is not watertight and will not print. I want to delete all the faces outside the cylinder but retain the ones created by the intersect_with command inside the cylinder.
model = Sketchup.active_model
entities = model.entities
entities.clear!
basegroup = entities.add_group
basegroupentities = basegroup.entities
center_point = Geom;;Point3d.new(0,0,0)
normal_vector = Geom;;Vector3d.new(0,0,1)
radius = 1000
edgearray = basegroupentities.add_circle center_point, normal_vector, radius
main_face = basegroupentities.add_face(edgearray)
main_face.reverse! if main_face.normal.z < 0
main_face.pushpull 1000
base_trans = basegroup.transformation
cutgroup=entities.add_group
cutgroupentities=cutgroup.entities
p1 = Geom;;Point3d.new(500, -50, 500)
p2 = Geom;;Point3d.new(1500, -50, 500)
p3 = Geom;;Point3d.new(1500, 200, 500)
p4 = Geom;;Point3d.new(500, 200, 500)
points = [p1,p2,p3,p4]
base = cutgroupentities.add_face points
base.reverse! if base.normal.z < 0
base.pushpull 1000
cut_trans=cutgroup.transformation
baz = Sketchup.active_model.entities.intersect_with true, cut_trans, basegroup.entities, base_trans , true, basegroup
basegroup.explode
#cutgroup.explode
model.active_view.zoom_extents
cutgroup.erase!
Any ideas on how to automate these processes?
Thanks!