Set_texture_projection

What is the best method within pro 2022 to project an image onto a curved face? My extension is using set_texture_projection but that is not support any more. I can’t get face.position_material to create a smooth image across a curved plain. This is the error I get with projection.

This method never worked properly and was removed in SketchUp 2021.1. Use face.position_material with the projection vector instead.

I can’t seem to find any newer content on the web for how to handle curved surfaces within images for pro 2022.

I have a tutorial video about that topic, from basics to advanced plugins, it is Turkish language but i think it is understandable…

I will need to create the ruby script. You used an extension to create your work. I am looking for an example of how to do it in Ruby or even how to add a smooth image to a curved surface without using projection native within Sketchup Pro 2022.

Sorry, i didn’t noticed that it is ruby section… :slight_smile:

I would like to add an image across the front of a curved face. I can’t seem to get this code to work correctly. Any Ideas?

model = Sketchup.active_model
entities = model.active_entities


# Add the face to the entities in the model
points = [
  Geom::Point3d.new(0, -1200, 0),
  Geom::Point3d.new(-5.43387120911019, -1189.44095529067, 0),
  Geom::Point3d.new(-5.84558479587266, -1188.64091752703, 8.00040054321289),
  Geom::Point3d.new(-0.41171347766655, -1199.19996244835, 8.00040054321289)
]
face = entities.add_face(points)

ptsSpine0 = []
ptsSpine0[0] = Geom::Point3d.new(0, -1200, 0)
ptsSpine0[1] = Geom::Point3d.new(3.2016, -1198.3524, 0)
ptsSpine0[2] = Geom::Point3d.new(32.5836, -1184.478, 0)
ptsSpine0[3] = Geom::Point3d.new(62.6604, -1172.184, 0)
ptsSpine0[4] = Geom::Point3d.new(93.3576, -1161.5364, 0)
ptsSpine0[5] = Geom::Point3d.new(124.5876, -1152.5652, 0)
ptsSpine0[6] = Geom::Point3d.new(156.2568, -1145.2992, 0)
ptsSpine0[7] = Geom::Point3d.new(188.2728, -1139.7576, 0)
ptsSpine0[8] = Geom::Point3d.new(220.542, -1135.9572, 0)
ptsSpine0[9] = Geom::Point3d.new(252.9696, -1133.9088, 0)
ptsSpine0[10] = Geom::Point3d.new(285.4608, -1133.6088, 0)
ptsSpine0[11] = Geom::Point3d.new(292.6584, -1133.7816, 0)
ptsSpine0[12] = Geom::Point3d.new(325.098, -1135.6524, 0)
ptsSpine0[13] = Geom::Point3d.new(357.3888, -1139.2644, 0)
ptsSpine0[14] = Geom::Point3d.new(389.436, -1144.62, 0)
ptsSpine0[15] = Geom::Point3d.new(421.1472, -1151.7024, 0)
ptsSpine0[16] = Geom::Point3d.new(452.4276, -1160.49, 0)
ptsSpine0[17] = Geom::Point3d.new(483.1872, -1170.9588, 0)
ptsSpine0[18] = Geom::Point3d.new(513.3348, -1183.0776, 0)
ptsSpine0[19] = Geom::Point3d.new(542.7828, -1196.8104, 0)
ptsSpine0[20] = Geom::Point3d.new(571.4424, -1212.12, 0)
ptsSpine0[21] = Geom::Point3d.new(574.56, -1213.92, 0)

edge = entities.add_edges(ptsSpine0)

face.followme(edge)

# Create a material and assign the texture to it
material = model.materials.add("Test Material")
material.texture = "/Users/jeffreygunderson/Library/Application Support/SketchUp 2022/SketchUp/TESTImage.jpg"

face.position_material(material, ptsSpine0, true)

You aren’t passing any projection vector in this case. Notice the method has two overloads: Class: Sketchup::Face — SketchUp Ruby API Documentation

Btw, can you post example model and texture so we can run the example with the same data (model/texture).