sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Apply Material to ALL Entities on a Layer.

    Scheduled Pinned Locked Moved Plugins
    17 Posts 8 Posters 5.2k Views 8 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.
    • mitcorbM Offline
      mitcorb
      last edited by

      @Pixero:
      Would you believe, I went looking at your collection of plugins, thinking that you had developed one for this purpose, when I posted just above.
      (I guess those by ThomThom were not the answer?)

      I take the slow, deliberate approach in my aimless wandering.

      1 Reply Last reply Reply Quote 0
      • F Offline
        faust07
        last edited by

        Look at this plugins:
        convert_materials_to_layer_names.rb (Al Hart) -
        http://sketchucation.com/forums/viewtopic.php?t=36715#p323129
        or
        layers_materials.rb (Didier Bur) -
        http://rhin.crai.archi.fr/rld/plugin_details.php?id=219

        1 Reply Last reply Reply Quote 0
        • A Offline
          atcad108
          last edited by

          Hello,
          First thanks to all since thanks of your kindness we have all this very usefull pluggins available.
          Then for this code I found it very usefull but it doesn't work for me. I am using sketchup 2013 Pro and I paste the code to the ruby console and much the layer and material names but nothing happens. I do like this:

          ln='LAYER2';mn='MATERIAL2';m=Sketchup.active_model;ma=nil;m.materials.each{|e|ma=e if e.display_name==mn};la=m.layers[ln];m.start_operation('@');m.definitions.each{|d|next if d.image?;d.entities.grep(Sketchup;;Face).each{|e|if e.material==ma;d.instances.each{|i|i.layer=la};break;end}};m.commit_operation;
          

          Please if someone can point out what I am doing wrong I really would appreciate very much.
          Thanks,

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            @atcad108

            Firstly be aware that the code finds all Entities which have the specified Material and assigns them the specified Layer.
            The Material's 'name' must already exist in the Model's Materials and be used by some Entities placed in the Model.
            The Layer 'name' will be added to the Layers if it does not exist.
            So in your example code you show:
            ln='LAYER2';mn='MATERIAL2';
            Does the Layer with that name, and the Material with that name already exist?
            Ensure you use the exact same names...

            TIG

            1 Reply Last reply Reply Quote 0
            • A Offline
              atcad108
              last edited by

              Ooohh sorry, I was thinking it goes the other way around. And yes the material and the layer already exist and are exanctly as 'LAYER2' and 'MATERIAL2'.
              But what I was trying to do is to apply a material to a layer, the material2 is in the model but not in this layer.
              In this case I have a model that it is organitzed by layers and the layers are in different components and groups and subgroups, and I would like to apply a material to a layer and it applies to all the model. Hopefully I explain it well...
              I thought this code was for that, sorry. Do you know if it is something like this already? It maybe but I couldn't find it.
              Anyway thanks you very much!

              1 Reply Last reply Reply Quote 0
              • sdmitchS Offline
                sdmitch
                last edited by

                @atcad108 said:

                Ooohh sorry, I was thinking it goes the other way around. And yes the material and the layer already exist and are exanctly as 'LAYER2' and 'MATERIAL2'.
                But what I was trying to do is to apply a material to a layer, the material2 is in the model but not in this layer.
                In this case I have a model that it is organitzed by layers and the layers are in different components and groups and subgroups, and I would like to apply a material to a layer and it applies to all the model. Hopefully I explain it well...
                I thought this code was for that, sorry. Do you know if it is something like this already? It maybe but I couldn't find it.
                Anyway thanks you very much!

                I have sent by Private Message a plugin that I think will do what you want.

                Nothing is worthless, it can always be used as a bad example.

                http://sdmitch.blogspot.com/

                1 Reply Last reply Reply Quote 0
                • A Offline
                  atcad108
                  last edited by

                  Sorry I replay by here, it says I can't send private messages.
                  First thank you very much, I think what you send it is exactly what I am looking for but I can't make it work.
                  How shall I do? I selected the layer and the material in the model and hit the pluggin but nothing come out. I don't know what should be the order or the way to make it work, please if you can tell me...
                  Thank you very much!

                  1 Reply Last reply Reply Quote 0
                  • TIGT Offline
                    TIG Moderator
                    last edited by

                    By now you should have enough cred to do PMs...

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • sdmitchS Offline
                      sdmitch
                      last edited by

                      @atcad108 said:

                      Sorry I replay by here, it says I can't send private messages.
                      First thank you very much, I think what you send it is exactly what I am looking for but I can't make it work.
                      How shall I do? I selected the layer and the material in the model and hit the pluggin but nothing come out. I don't know what should be the order or the way to make it work, please if you can tell me...
                      Thank you very much!

                      You don't have to do anything just execute the plugin. It should apply MATERIAL0 to LAYER0 and so on. There is no output of any kind. If you pre-select some entities, then it only processes them and ignores the rest of the model.

                      I guess I sent the plugin to the wrong person since you are not the originator of this thread.

                      Nothing is worthless, it can always be used as a bad example.

                      http://sdmitch.blogspot.com/

                      1 Reply Last reply Reply Quote 0
                      • A Offline
                        austinryan
                        last edited by

                        Just a dumb couple of questions

                        1. when running the script it does not paint the reverse faces. can this be done?
                        2. is there a way to make a toolbar using this script for multiple layers and materials?

                        Thanks in advance

                        1 Reply Last reply Reply Quote 0
                        • TIGT Offline
                          TIG Moderator
                          last edited by

                          If you want the same material front & back...
                          Change where it says ... e.material=ma if e.layer==la...
                          To ... (e.material=ma;e.back_material=ma) if e.layer==la...

                          The toolbar is another kettle of fish...

                          TIG

                          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