Using default sketchup materials with Ruby API
-
I think I'm missing something in the docs, but can anyone tell me how to assign default sketchup materials to faces? The docs seem to be for Sketchup 4 and talks about .jpg files.
I tried the following code but it just changes the material to black:
materials = Sketchup.active_model.materialsm = materials.add "opening" m.texture="c;\\Program Files\\@Last Software\\Google SketchUp 6\\Materials\\Translucent\\Translucent_Glass_Sky_Reflection.skm" face.material = m
Any help would be great.
Thanks.
-
Do you really have GSU6 installed under "@Last Software" ??
That would be my first guess. -
I dont know if this is your problem or not but...
I found a bug a while back where if I tried to apply a material with a texture that wasn't already in the model it would to unpredictable things including crash. Try adding that material to something by hand before you try to assign in using ruby.
Chris
@mocathe1st said:
I think I'm missing something in the docs, but can anyone tell me how to assign default sketchup materials to faces? The docs seem to be for Sketchup 4 and talks about .jpg files.
I tried the following code but it just changes the material to black:
materials = Sketchup.active_model.materials> m = materials.add "opening" > m.texture="c;\\Program Files\\@Last Software\\Google SketchUp 6\\Materials\\Translucent\\Translucent_Glass_Sky_Reflection.skm" > face.material = m >
Any help would be great.
Thanks.
-
This code works for me:
model = Sketchup.active_model
materials=model.materialsAdds a material as an in model material
m = materials.add "Test Color"
beginReturns nil if not successful, path if successful
path=Sketchup.find_support_file "1.jpg","\Plugins\"
# m.texture = "1.jpg"
m.texture = path
m.texture.size = 666
rescue
UI.messagebox $!.message
end
Advertisement