The documentation on how exactly to use this method in the API seems a bit sparse to me or at least I’m not figuring it out very well.
In this particular case I am interested in using position_material on horizontal faces in my group hence you will see that I use the normal vector for the faces of interest in my test code below.
I have been getting the pure translation to work, that one is easy with only two points:
# Pure Translation
pt_array = []
pt_array[0] = Geom::Point3d.new(@Flooring_offsetx,@Flooring_offsety,0)
pt_array[1] = Geom::Point3d.new(0,0,0)
face_list = group1.entities.grep(Sketchup::Face)
mainfaces = face_list.find_all {|f| f.normal.parallel?(Z_AXIS)}
for facei in mainfaces
facei.material = @Flooring_mat
facei.position_material(@Flooring_mat, pt_array, true)
end
The one that is giving me problems is the pure rotation (eight points), it is rotating as expected but it is also scaling the material very small. Obviously I’m missing something here.
# Pure Rotation
phi = @Flooring_rot.degrees
pt_array = []
pt_array[0] = Geom::Point3d.new(0,0,0)
pt_array[1] = Geom::Point3d.new(0,0,0)
xp2 = cos(phi)
yp2 = sin(phi)
pt_array[2] = Geom::Point3d.new(xp2,yp2,0)
pt_array[3] = Geom::Point3d.new(1.0,0,0)
xp3 = cos(phi) - sin(phi)
yp3 = sin(phi) + cos(phi)
pt_array[4] = Geom::Point3d.new(xp3,yp3,0)
pt_array[5] = Geom::Point3d.new(1.0,1.0,0)
xp4 = -sin(phi)
yp4 = cos(phi)
pt_array[6] = Geom::Point3d.new(xp4,yp4,0)
pt_array[7] = Geom::Point3d.new(0,1.0,0)
face_list = group1.entities.grep(Sketchup::Face)
mainfaces = face_list.find_all {|f| f.normal.parallel?(Z_AXIS)}
for facei in mainfaces
facei.material = @Flooring_mat
facei.position_material(@Flooring_mat, pt_array, true)
end
I do not want any scaling, just rotation.