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

[REQ] layer attribute from geometry to group

Scheduled Pinned Locked Moved Plugins
3 Posts 2 Posters 137 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 5 Apr 2013, 11:44

    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
    • T Offline
      TIG Moderator
      last edited by 5 Apr 2013, 11:57

      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 5 Apr 2013, 12:51

        TIG,

        Thank you very much! That worked great.

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

        Advertisement