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!
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Method to Explode Groups by name beginning...

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 196 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.
    • S Offline
      Skastafari
      last edited by

      I need help with a method to explode select groups in my model, they are named "wall*".
      So they would appear in model as "wall_1_3, wall_1_4, etc. They must all be exploded, but nothing else in the model. They are not sub-grouped, so no re-curse needed. I was playing with something like...

      model=Sketchup.active_model
      entities=model.active_entities
      Sketchup.active_model.active_entities.each{|e|e.explode if e.name =~ /\A(wall-)/}

      This does not work. I am unsure of method and syntax, and being humbled my now apparent limited skills. Any help would be appreciated.

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

        Try

        Sketchup.active_model.active_entities.grep(Sketchup;;Group).each{|e| e.explode if e.name=~/^[Ww]all/ }
        

        Any group in the current active entities that has a name starting with [Ww]all should be exploded...
        Obviously enclosing it in a module/method and start/commit_operation is needed...
        But this the core code...

        TIG

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

          Looks like you focused only on group class, and corrected the wall name syntax, and I am very grateful as it now works! Thanks Tig 😎

          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