Hey everyone,
I’m trying to write a simple Ruby script that does the following:
- Takes a material named
"TestTexture"
from the model - Applies it to a face I select
- Aligns and stretches the texture so it fits exactly to the face’s bounding rectangle
- Starts from the lower-left corner, aligned with the face orientation
What I’ve already tried:
- Using
face.position_material(material, pt0, pt1, pt2)
with 3 validPoint3d
- Ensuring the points are not collinear, and lie within the face plane
- Using clean bounding box points (
face.bounds.min
) and offsetting by axes - Also tried projecting from face center using
face.normal
,xaxis
,yaxis
- Even tried using 8-argument version of
position_material
(with UVs) — which isn’t supported - Attempted to work with
face.uv_set
— turns out not exposed in Ruby API - Also tried using
UVHelper
to assist with coordinate mapping
No matter what I try, position_material
almost always throws this error:
ArgumentError: Cannot convert argument to Geom::Vector3d
Any ideas or sample code would be a huge help
Thanks in advance!