• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Method to Explode Groups by name beginning...

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 179 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 5 Jun 2014, 16:40

    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
    • T Offline
      TIG Moderator
      last edited by 5 Jun 2014, 16:45

      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 5 Jun 2014, 18:10

        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
        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