I find a bug about material

I can’t paste this material through code, but That of using SketchUp paint tool is ok.

use ruby code

face = Sketchup.active_model.selection[0]
material = Sketchup.active_model.materials['image']
face.material = material
# Error: #<ArgumentError: Cannot assign image material to model entities>
# <main>:2:in `material='
# <main>:2:in `<main>'
# SketchUp:in `eval'
# => nil

use paint tool

material = Sketchup.active_model.materials['image']
Sketchup.active_model.materials.current = material
# then use paint tool

test.skp (172.4 KB)

You can only assign manager owned materials to drawingelements.


For image owned materials you must go through an ImageRep and create a new material.

matls = Sketchup.active_model.materials
texture = matls["image"].texture
img_rep = texture.image_rep
matl = matls.add("my new materlal")
matl.texture= img_rep

Thank you.