Material.Texture not working as explained in the doc
-
Dear all,
I'm becoming crazy with the materials and textures classes.I want to create a new material, based on an existing one applied to an object, with the same texture, but to apply different colorizations.
So I tried :
lets say the object is selected :
entity=Sketchup.active_model.selection[0]
existingmat = entity.material
if entity.material.texture != nil
newmat = Sketchup.active_model.materials.add
newmat.texture = existingmat.texture
endThe SU documentation says that "Material.texture=" method receives as an argument a texture class or nil.
In fact when running this code, I got the message from Sketchup : #<ArgumentError: Texture filename or nil required>I tried this with existing textures in sketchup.
PS : another strange thing, if i ask for texture.filename, it returns "xxxxname.jpg" even if the jpg file does not exists on the disk (in fact the skm file only exists).
So do I have to export the texture with texture writer to create an copy of an existing texture ?
Yours
PascalPS : trying to put the last updates on Tree Maker Plugin.
-
Yes, the description in the docs is wrong. (Adding an issue for that.)
But the example (messy example) does demonstrate the correct way - using a string with the path to an image resource.Texture.filename refer to the file the texture was originally created from. But all textures are embedded in the SKP file - so you cannot expect to find the texture file at that location. You need to use the TextureWriter for that.
-
Thanks a lot for your answer.
F.....g doc and su apis.
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