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

    Selecting all edges in selection cycling through groups

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 6.2k Views 3 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.
    • B Offline
      baldaman
      last edited by

      Is it possible, via ruby, to select all edges within a selection cycling through hierarchy (groups, components, nested groups etc...)?
      My final goal is to paint them with the material of my choice.
      Thanks in advance Ruby masters!

      1 Reply Last reply Reply Quote 0
      • S Offline
        slbaumgartner
        last edited by

        Well, yeah it's possible. The current selection is an enumerator of Entities. Use its #grep method to extract the Entities of interest: Sketchup::Edge, Sketchup::Group, Sketchup::ComponentInstance. For loose Edges, you can immediately apply the material. For Groups or ComponentInstances, proceed recursively using that same process applied to the Group or ComponentInstance's ComponentDefinition's Entities collection instead of the active selection. The one thing you should be aware of is that for ComponentInstances, you can't color the Edges in one without also affecting them in all other instances regardless of where or how the others are nested. Similarly, if you have copied a Group, altering anything in one will make it unique from the others and will not affect them.

        1 Reply Last reply Reply Quote 0
        • TNTDAVIDT Offline
          TNTDAVID
          last edited by

          Hellobaldaman,

          Here is an example code that will allow you to select all the edges:

          def select_all_edges(ents, edges)
            ents.grep(Sketchup;;ComponentInstance).each do |e|
              e.definition.entities.grep(Sketchup;;Edge).each do |e|
                edges << e
              end
              select_all_edges(e.definition.entities, edges)
            end
          end
          
            edges = []    	
            mod = Sketchup.active_model
            sel = mod.selection
            select_all_edges(sel, edges)
            sel.clear
            sel.add(edges)
          

          Note that you do not have to select the edges to apply a ruby transformation on the edges.

          Cordially

          David

          [b:8wt9py2i]* Nouveau !!![/b:8wt9py2i] Découvrez notre nouveau Plugin [url=http://www.composant-dynamique.com/:8wt9py2i][color=#40FF00:8wt9py2i]C[/color:8wt9py2i][color=#77FF00:8wt9py2i]l[/color:8wt9py2i][color=#ADFF00:8wt9py2i]i[/color:8wt9py2i][color=#E4FF00:8wt9py2i]c[/color:8wt9py2i][color=#FFDB09:8wt9py2i]k[/color:8wt9py2i][color=#FF921B:8wt9py2i]-[/color:8wt9py2i][color=#FF492E:8wt9py2i]C[/color:8wt9py2i][color=#FF0040:8wt9py2i]u[/color:8wt9py2i][color=#ED2577:8wt9py2i]i[/color:8wt9py2i][color=#DA49AD:8wt9py2i]s[/color:8wt9py2i][color=#C86EE4:8wt9py2i]i[/color:8wt9py2i][color=#AD77FF:8wt9py2i]n[/color:8wt9py2i][color=#8965FF:8wt9py2i]e[/color:8wt9py2i] [color=#4040FF:8wt9py2i]2[/color:8wt9py2i][/url:8wt9py2i], pour créer vos cuisines 3D !

          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