• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Put groups within groups to layers

Scheduled Pinned Locked Moved SketchUp Discussions
sketchup
4 Posts 2 Posters 296 Views
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.
  • H Offline
    harnstein
    last edited by 22 Sept 2012, 14:52

    Hi all,

    when i'm exporting a SU file to 3ds Max it splits the file according to the layer structure.

    But it always uses the layer of each group, eg. i have a layer "Level1" with serveral groups. But these groups contain subgroups- and these subgroups are still an layer0 -> and therefor put to "Layer0" in 3Ds.

    Is there a way to put all nested groups to one specific layer?

    (All geometry is still on layer0)

    Thanks in advance..

    Niko

    still sketchin'

    1 Reply Last reply Reply Quote 0
    • S Offline
      sdmitch
      last edited by 22 Sept 2012, 15:51

      Do you want to specify the layer or just move all subgroups to the layer of the the top group?

      If it is the later then

      mod = Sketchup.active_model
      ent = mod.active_entities
      sel = mod.selection
      
      sel.each{|ga|
       if ga.class==Sketchup;;Group
        ga.entities.each{|gb|
         if gb.class==Sketchup;;Group
          gb.layer=ga.layer
          gb.entities.each{|gc|
           if gc.class==Sketchup;;Group
            gc.layer=ga.layer
            gc.entities.each{|gd|
             if gd.class==Sketchup;;Group
               gd.layer=ga.layer
             end
            }
           end
          }
         end
        }
       end
      }
      
      

      will handle groups nested up to 4 deep.

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

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • H Offline
        harnstein
        last edited by 2 Oct 2012, 12:16

        Hey,

        sorry for my late reply- i was really busy with a project and therefor needed to take a break not seeing my computer for a while afterwards. 😉

        Forum was down for maintenance on sunday- and wow, a complete makeover!


        Back to topic, thanks for your help!

        But i could not get it to work- how is it meant to be handled?

        I made a *.rb file with notepad but it gave me some error message when loaded.

        Pasting it into the ruby console did't work as i can paste one line only..

        I feel like i missed something as i think i remember that i had pasted some lines somewhere some time before.. but i don't know.

        ??

        And, is it possible to extend the number of groups by adding lines in the same pattern like you did:

        if ga.class==Sketchup::Group
        ga.entities.each{|gb|
        if gb.class==Sketchup::Group

        and so on?

        And relating number of brackets for sure.

        still sketchin'

        1 Reply Last reply Reply Quote 0
        • S Offline
          sdmitch
          last edited by 6 Oct 2012, 01:51

          Sorry for the late reply but I have been away all week. The code, as presented, was created and executed in Ruby Web Console. To make it a stand-alone plugin you would need to "wrap" it in a module and def like this.

          
          module G2L
          def g2l
          mod = Sketchup.active_model
          ent = mod.active_entities
          sel = mod.selection
          
          sel.each{|ga|
           if ga.class==Sketchup;;Group
            ga.entities.each{|gb|
             if gb.class==Sketchup;;Group
              gb.layer=ga.layer
              gb.entities.each{|gc|
               if gc.class==Sketchup;;Group
                gc.layer=ga.layer
                gc.entities.each{|gd|
                 if gd.class==Sketchup;;Group
                   gd.layer=ga.layer
                 end
                }
               end
              }
             end
            }
           end
          }
          end
          end
          
          

          Place a copy in the Plugins folder so that it gets loaded when Skethsup starts. Then in the Ruby Console enter G2L.g2l to execute it.

          Yes, you can add as many as you need.

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

          http://sdmitch.blogspot.com/

          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