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 = mAny 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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register LoginAdvertisement