概要
windows11に、sketchup6を入れてみた。
rubyで、3Dを書く。
解決できていない、課題がある。
課題
オブジェクトでオブジェクトを削除する。
できた所
オブジェクトでオブジェクトに跡を付ける。
できない所
オブジェクトでオブジェクトの交差を削除する。
写真
サンプルコード
def cuttest1
model = Sketchup.active_model
entities = model.entities
basegroup = entities.add_group
basegroupentities = basegroup.entities
p1 = Geom::Point3d.new(0, 0, 0)
p2 = Geom::Point3d.new(20, 0, 0)
p3 = Geom::Point3d.new(20, 1, 0)
p4 = Geom::Point3d.new(0, 1, 0)
p5 = Geom::Point3d.new(0, 0, 0)
points = [p1, p2, p3, p4, p5]
base = basegroupentities.add_face points
normal = base.normal
if normal == [0, 0, -1]
base = base.reverse!
end
base.pushpull 10
base_trans = basegroup.transformation
cutgroup = entities.add_group
cutgroupentities = cutgroup.entities
p1 = Geom::Point3d.new(5, -1, 5)
p2 = Geom::Point3d.new(15, -1, 5)
p3 = Geom::Point3d.new(15, 2, 5)
p4 = Geom::Point3d.new(5, 2, 5)
p5 = Geom::Point3d.new(5, -1, 5)
points = [p1, p2, p3, p4, p5]
base = cutgroupentities.add_face points
normal = base.normal
if normal == [0, 0, -1]
base = base.reverse!
end
base.pushpull 10
cut_trans = cutgroup.transformation
cutgroupentities.intersect_with false, cut_trans, basegroup, base_trans, true, basegroup
basegroup.explode
UI.messagebox("Click to delete cut group.")
cutgroup.erase!
end
以上。