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

    [REQ] layer attribute from geometry to group

    Scheduled Pinned Locked Moved Plugins
    3 Posts 2 Posters 150 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.
    • J Offline
      j_forrester
      last edited by

      I believe there was recently a post asking for the reverse of this. I have received a model which has all layer attributes assigned to the actual geometry (faces/edges). When i try and export this to an external program it does not pick up the layer information as the top most groups are all showing Layer 0.

      What i need is a script that recursively goes through all geometry and assigns the same layer attributes to the parent group(s) or components.

      Does anyone know of such a script or if it is not too difficult have a quick play and see what is achievable?

      Any help would be very much appreciated.

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

        Are all entities inside each group/component-definition on a single layer.
        It's unworkable if not...
        If they are.... you can use:

        m=Sketchup.active_model;ds=m.definitions;m.start_operation('x');ds.each{|d|d.instances.each{|i|i.layer=d.entities[0].layer}};m.commit_operation;
        

        copy+pasted into the Ruby Console + <enter>.
        It is one-step undo-able.

        If you want to give the group/instance the internal contents' layer AND also revert the faces/edges in it to Layer0, this alternative is what you need:

        m=Sketchup.active_model;ds=m.definitions;m.start_operation('x');ds.each{|d|d.instances.each{|i|i.layer=d.entities[0].layer};d.entities.grep(Sketchup;;Face).each{|e|e.layer=nil};d.entities.grep(Sketchup;;Edge).each{|e|e.layer=nil};};m.commit_operation;
        

        We can't try to revert everything to Layer0 because if you have nested groups they'll be all over the shop as their layer alters...

        TIG

        1 Reply Last reply Reply Quote 0
        • J Offline
          j_forrester
          last edited by

          TIG,

          Thank you very much! That worked great.

          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