sketchucation logo sketchucation
    • Login
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    [REQ] layer attribute from geometry to group

    scheduled pinned locked moved Plugins
    3 Posts 2 Posters 142 Views 2 Watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • 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.

      one-reply-to-this-post last-reply-time 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

        one-reply-to-this-post last-reply-time reply quote 0
        • J Offline
          j_forrester
          last edited by

          TIG,

          Thank you very much! That worked great.

          one-reply-to-this-post last-reply-time 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