Images are strange beasts that are confusing to manipulate via the Ruby API. I’m not where I can write and test sample code just now, but the general idea is:
- add the image as you have done
- create a sequence of Geom:Transformations that moves and rotates the image appropriately to place it in front of the target Face
- use image#transform! to put the image in the required place
There are lots of gotchas along the way that the basics above don’t elaborate.
When first imported, the image’s upper left corner will be at the point you used in add_image and it will always lay flat on the red-green plane.
You will likely want to place the image’s center point at the center of the Face. The image’s initial center point is at (image.width/2, image.height/2, 0). You can find the geometric center of a Face by, for example, ctr=face.bounds.center. So you need to move the image using a translate Transformation based on the Vector3d from the image center to the face center.
Then you will want to rotate the image about its center and the appropriate axis to align it with the face. If you are doing walls, these rotations will most likely be purely around the X_AXIS or Y_AXIS depending on the direction of the wall’s normal.
Finally, SketchUp has a perverse habit of putting the image onto the back of a face, where it looks reversed. To get it showing on the front, translate it a small amount along the Face’s normal so that it comes proud of the surface.