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

How do you get a group's definition?

Scheduled Pinned Locked Moved Developers' Forum
7 Posts 3 Posters 343 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.
  • T Offline
    thomthom
    last edited by 12 Dec 2008, 14:57

    When you copy a group the Entity Window displays how many copies there exist of that group.
    You can also find the definition in Sketchup.active_model.definitions
    but, is there a way to get the definition from the Group object instead of iterating through the Sketchup.active_model.definitions and compare every definition there is?

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

    1 Reply Last reply Reply Quote 0
    • R Offline
      RickW
      last edited by 12 Dec 2008, 17:36

      One way would be to create an empty group inside that group, then query the parent of the empty group.

      definition = (group.entities.add_group).parent
      

      The empty group is volatile, and will be automatically purged by any operation affecting the model geometry. It's not a nice way to do it, but it works.

      Just curious - why do you need the definition?

      RickW
      [www.smustard.com](http://www.smustard.com)

      1 Reply Last reply Reply Quote 0
      • T Offline
        thomthom
        last edited by 12 Dec 2008, 17:50

        hm... if I edit that group, then won't it make it unique?

        I want to get all the copied entities of a group so I can make a plugin that allows you to select all of these all at once. I often find myself with old models at the office where the original creator have created lots of copies of an object as an group instead of components.

        So I want to be able to quickly select copies of groups. And then I'll make a function that will allow me to convert all these copies to components.

        Just wanted to check if there was an easier way to do this without looping through the instances array every time.

        btw Rick, on a sidenote, I saw your Instances script, and I was surprised that SU allows you to select objects that's nested deep within groups and components. Unexpected, but potentially very useful.

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

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 12 Dec 2008, 17:52

          And won't your code actually return the same as what 'group' returns?

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

          1 Reply Last reply Reply Quote 0
          • W Offline
            Whaat
            last edited by 12 Dec 2008, 19:41

            group.entities.parent
            

            is all you need to get the definition of any group

            SketchUp Plugins for Professionals

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 13 Dec 2008, 12:18

              That's great Dale! Works perfectly.

              But I would never that expected that .parent would return that. I would have expected that:

              
              group.entities.parent === group
              
              

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

              1 Reply Last reply Reply Quote 0
              • R Offline
                RickW
                last edited by 15 Dec 2008, 16:42

                @thomthom said:

                That's great Dale! Works perfectly.

                But I would never that expected that .parent would return that. I would have expected that:

                
                > group.entities.parent === group
                > 
                

                There are a lot of strange things about groups, and that is one of them.

                RickW
                [www.smustard.com](http://www.smustard.com)

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                1 / 1
                • First post
                  3/7
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement