Sorry for the formatting issues and stupid mistakes, I am new to Sketchup and the ruby API. So that code works for my flat faces, but would it be possible to apply the projected texture to the created face on a curved object created with a followme command? See the code below and the pictures of my current result.
model = Sketchup.active_model
entities = model.active_entities
texture_path = Sketchup.find_support_file "Cinder Block.skm", "Materials/Brick, Cladding and Siding/"
materials = Sketchup.active_model.materials
wallmat = materials.load(texture_path)
#Draw the face for the texture - face
pts = []
pts[0] = [412.788708358203, -439.271997369409, 0]
pts[1] = [437.268708358203, -462.311997369409, 0]
pts[2] = [437.268708358203, -462.311997369409, 7.75]
pts[3] = [412.788708358203, -439.271997369409, 7.75]
#Add the face To the entities In the model
face1 = entities.add_face(pts)
face1.material = wallmat
edges = face1.edges
#Project texture
face1.set_texture_projection(face1.normal, true)
#Draw the block - side face
pts19 = []
pts19[0] = [659.519881381513, -177.119993425486, 0]
pts19[1] = [659.425889486804, -165.12036153431, 0]
pts19[2] = [659.419509333829, -164.30582867111, 7.75]
pts19[3] = [659.513501228538, -176.305460562286, 7.75]
entities19 = model.active_entities
face2 = entities19.add_face pts19
#create test curve to follow
ptsSpine19 = []
ptsSpine19[0] = Geom::Point3d.new(659.519881381513, -177.119993425486, 0)
ptsSpine19[1] = Geom::Point3d.new(663.114, -177.3192, 0)
ptsSpine19[2] = Geom::Point3d.new(664.4076, -177.9048, 0)
ptsSpine19[3] = Geom::Point3d.new(665.7396, -178.278, 0)
ptsSpine19[4] = Geom::Point3d.new(667.0488, -178.7208, 0)
ptsSpine19[5] = Geom::Point3d.new(668.3328, -179.2344, 0)
ptsSpine19[6] = Geom::Point3d.new(669.5868, -179.814, 0)
ptsSpine19[7] = Geom::Point3d.new(670.8096, -180.4608, 0)
ptsSpine19[8] = Geom::Point3d.new(671.9952, -181.1724, 0)
ptsSpine19[9] = Geom::Point3d.new(673.2816, -181.7388, 0)
ptsSpine19[10] = Geom::Point3d.new(678.5112, -186.6876, 0)
ptsSpine19[11] = Geom::Point3d.new(679.1472, -187.9404, 0)
ptsSpine19[12] = Geom::Point3d.new(679.9224, -189.0852, 0)
ptsSpine19[13] = Geom::Point3d.new(680.6364, -190.2696, 0)
ptsSpine19[14] = Geom::Point3d.new(681.2844, -191.4912, 0)
ptsSpine19[15] = Geom::Point3d.new(681.8676, -192.744, 0)
ptsSpine19[16] = Geom::Point3d.new(682.3824, -194.0268, 0)
ptsSpine19[17] = Geom::Point3d.new(682.8288, -195.336, 0)
ptsSpine19[18] = Geom::Point3d.new(683.6028, -196.5816, 0)
ptsSpine19[19] = Geom::Point3d.new(683.969052265305, -199.881189894678, 0)
edge = entities.add_curve(ptsSpine19)
#Copy projected texture from face1 to face2
def copy_projected_face_material(face1,face2)
unless face1.material.nil?
frontside = true
face2.material= face1.material
face2.set_texture_projection( face1.get_texture_projection(frontside), frontside )
end
unless face1.material.nil?
frontside = false
face2.back_material= face1.material
face2.set_texture_projection( face1.get_texture_projection(frontside), frontside )
end
nil
end
copy_projected_face_material(face1,face2)
#Create a solid from from the block face
face2.followme(edge)