sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Sketchup.active_model.materials.current behaviour

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 2 Posters 224 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.
    • S Offline
      spratman
      last edited by

      I am writing a script to change the material for specific part of the model. The idea is that the user will select a material from the Materials window then they will run the script which will use the current material to change some parts of the active model. To get the current material I am using Sketchup.active_model.materials.current. This seems to return the last material that was used (i.e. you actually have to apply it to a face), selecting a new material in the Materials window is not sufficient to change the value of Sketchup.active_model.materials.current.

      Any suggestions on how I can determine the material that is selected in the Materials window?

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        I don't see that behaviour. When the selected material is changed, Sketchup.active_model.materials.current reflects that.
        (SU7)

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          When do you call that method?

          Thomas Thomassen β€” SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • S Offline
            spratman
            last edited by

            Here is a simple example using the Ruby Console:

            Show the current material:

            
             > printf "%s\n", Sketchup.active_model.materials.current.name
             \[Color_D05]
             nil
            
            

            Select a new material in the materials window, check the current material again:

            
             > printf "%s\n", Sketchup.active_model.materials.current.name
             \[Color_D05]
             nil
            
            

            Fill a face with the new material, then check the current material:

            
             > printf "%s\n", Sketchup.active_model.materials.current.name
             \[Color_F09]
             nil
            
            

            Sketchup.active_model.materials.current does not change until the last step

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              Maybe it's a Mac bug. Because on my PC it updates correctly.
              I'll test on my mac later when I get time.

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

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

              Advertisement