sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Grouping and ungrouping

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 11.6k 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.
    • R Offline
      Remmel
      last edited by

      Hi There, i wonder..... when you make an group with ruby in sketchup.... you can explode
      that group.... but is it possible to make the same group egain...???
      can anyone help me...?

      see the following simple exaample

      #create a group and add a line into the group
      model = Sketchup.active_model # Open model
      entities = model.entities # All entities in model
      selection = model.selection # Current selection
      group = entities.add_group #make emplty group

      #create a line in group
      line = group.entities.add_line [0,0,0], [100,50,20]

      #explode group
      group.explode

      1 Reply Last reply Reply Quote 0
      • jujuJ Offline
        juju
        last edited by

        That would probably require some method of recording what was previously selected. I'm not a developer, so I can't help you on the coding, but I recall a plugin / extension called "selection memory" (by Thom-Thom) that does more-or-less what may be required, in part at least. Maybe also take a look at "selection manager" for reference.

        Save the Earth, it's the only planet with chocolate.

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

          Use model.active_entities, working in model.entities IF it's not the current context will BugSplat.

          You can get references to the objects which result from the explode operation [any previous reference to that line etc will get lost as it explodes]
          exps = group.explode
          Gives you an array - in your case it'll probably be an array containing one line...

          You could then remake a group in the active_entities with group2 = entities.add_group(exps) or perhaps exps.grep(Sketchup::Edge)[0]

          If you want to replicate the group then after the first group is made you simply add a copy of it, then explode the original, so that the edge is now in the copied group, and it is replicated back in the active_entities...

          group.entities.add_line(...) group2 = entities.add_instance(group.definition, group.transformation)

          Now explode the original 'group' back to the edge in the active_entities...
          The second copy 'group2' remains, it contains the replicated edge...

          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