Hello, I’m working on modeling objects using the Followme function. If you do face.followme(edge), the result is Boolean, so I have to change the Face to Group or ComponentInstance to perform followme.
The flowme to the Z-axis operates normally, but sometimes it does not work normally with the X-axis.
The way we’re going is to click on the lines and enter the code. I’d like to ask you, including the picture that is error-prone.
The code is as follows.
Why? I need your help.
ents = Sketchup.active_model.entities
sel = Sketchup.active_model.selection
b = 100/25.4
h = 100/25.4
t1 = 6/25.4
t2 = 8/25.4
eee= (h/2 - t2)
sel.each do |ss|
if ss.is_a?(Sketchup::Edge)
po = ss.start.position
x = po.x
y = po.y
z = po.z
pts = Array.new
pts1 = Array.new
pt1 = Geom::Point3d.new(x - b/2, y , z + h/2)
pt2 = Geom::Point3d.new(x + b/2, y , z + h/2)
pt3 = Geom::Point3d.new(x + b/2, y , z - h/2)
pt4 = Geom::Point3d.new(x - b/2, y , z - h/2)
pt5 = Geom::Point3d.new(x - (b/2-t2) , y , z + (h/2-t1))
pt6 = Geom::Point3d.new(x + (b/2-t2), y , z + (h/2-t1))
pt7 = Geom::Point3d.new(x + (b/2-t2), y , z - (h/2-t1))
pt8 = Geom::Point3d.new(x - (b/2-t2), y , z - (h/2-t1))
pts.push(pt1, pt2, pt3, pt4)
pts1.push(pt5, pt6, pt7, pt8)
face = ents.add_face(pts)
face1 = ents.add_face(pts1)
face1.erase!
gp = ents.add_group(face)
face.reverse!
face.followme(ss)
cp = gp.to_component
end
end