• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Material.Texture not working as explained in the doc

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 187 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    ppoublan
    last edited by 20 Jan 2014, 13:36

    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
    end

    The 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
    Pascal

    PS : trying to put the last updates on Tree Maker Plugin.

    1 Reply Last reply Reply Quote 0
    • T Offline
      tt_su
      last edited by 20 Jan 2014, 14:36

      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.

      1 Reply Last reply Reply Quote 0
      • P Offline
        ppoublan
        last edited by 20 Jan 2014, 14:56

        Thanks a lot for your answer.
        F.....g doc and su apis.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          2/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement