sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Groups, Instances and Entities...

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 116 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.
    • N Offline
      noelwarr
      last edited by

      I know this subject seems to go on for ever but I've come across a particularly interesting bug and wanted to share it. We have an instance with a bunch of entities that we can capture in an array. That should look something like

      a = instance.definition.entities.to_a

      Theoretically I should now be able to group the entities like this (I am using Sketchup ๐Ÿ˜Ž

      instance.definition.entities.add_group a

      What is particularly interesting about this is that if I am in an edit session within the instance all works fine. If I am outside the instance strange things start happening. The group appears outside but is not clickable and disappears when I enter the edit session. If I delete the instance and click on the group I get a bug splat. Wierd

      Anyone care to shed some light as to what is going on?

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Yes, it's prone to oddities. There's a few threads here on that topic: add_group site:http://forums.sketchucation.com

        http://forums.sketchucation.com/viewtopic.php?f=180&t=39518#p349216

        Thomas Thomassen โ€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

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

          This a long and established limit.
          You should only ever use
          grp=ents.add_group(array)
          when the array of entities is in the active_entities context - hence the success during an edit but a failure during another session where the objects you are trying to group are not within the active context...
          You can do a workaround making an empty group and adding duplicates of the objects to that group.
          For groups/instances you can simply add another instance, but for other objects you need to 'clone' them, making duplicates of raw geometry edges/faces etc replicating their layer/material/hidden-state/attributes etc.
          It's often easier to create these objects in the correct context initially, but there are times when you want to affect existing things...
          So if you have two groups [grp1,grp2] inside another group [grp] that you want to 'combine' inside a single group [grp3], use this approach.
          grp3=grp.entities.add_group() g1=grp3.entities.add_instance(grp1.entities.parent, grp1.transformation) g2=grp3.entities.add_instance(grp2.entities.parent, grp2.transformation) grp1.erase! grp2.erase!
          Now 'grp' contains 'grp3' which contains 'grp1' and 'grp2'.
          If you wanted to merge the contents of these two groups I've left you two references...
          g1.explode g2.explode
          Now 'grp' contains 'grp3', which contains all of the entities that were previously inside 'gr1' and 'g2' [i.e. they are now 'exploded'].

          This has been covered in several posts... if you trawl through them... as thomthom suggests...

          TIG

          1 Reply Last reply Reply Quote 0
          • N Offline
            noelwarr
            last edited by

            Sorry for rehashing old problems. I did look around the forums. Guess I just wasn't looking properly. Your reply was clear and concise TIG. I tried your code out and it worked a charm. Cheers!

            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