Hi guys, I am really struggeling to get the right parameters when trying to add a planar mapping to mapping channel 9 of an object.
When I run the script I get this error:
Message: expected TextureMapping, got type
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
def addPlanarMapping(obj_id,channel):
bbox=rs.BoundingBox(obj_id)
tm = Rhino.Render.TextureMapping
plane = rs.WorldZXPlane()
plane.Origin = bbox[0]
dx= Rhino.Geometry.Interval(0,rs.Distance(bbox[0],bbox[1]))
dy=Rhino.Geometry.Interval(0,rs.Distance(bbox[0],bbox[4]))
dz=Rhino.Geometry.Interval(0,1)
tm.CreatePlaneMapping(plane,dx,dy,dz)
object = sc.doc.Objects.Find(obj_id)
object.SetTextureMapping(channel,tm)
obj_id = rs.GetObject("mesh",rs.filter.mesh,preselect=True)
if obj_id: addPlanarMapping(obj_id,9)