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

    [Bug] Add_group inside a component

    Scheduled Pinned Locked Moved Developers' Forum
    19 Posts 5 Posters 865 Views 5 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.
    • thomthomT Offline
      thomthom
      last edited by

      @matt666 said:

      However I think it's the .add_group function is bugged...

      Well, there sure is something about it, as the manual says: http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/entities.html#add_group

      @unknownuser said:

      NOTE: calling add_group with entities in its parameters has been known to crash SketchUp. It is preferable to create an empty group and then add things to its Entities collection.

      Though, how you go about not providing entities to the method's argument, I don't know. http://www.sketchucation.com/forums/scf/viewtopic.php?f=180&t=17153

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

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

        @matt666 said:

        I tried to create a group of all entities from the definition, and it create the group on the origin of the definition. And when you close the drawing, it bugs. So when you try this 'component.definition.entities.add_group(sub_component)' and you aren't inside this component on your model space, it bugs.

        Exactly the same as what I see. Wonder if we could summon a SU developer to provide some feedback.

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

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

          # get the required component-definition and the required transformation...
          g1 = model.active_entities.add_group
          g1ents = g1.entities
          g1ents.add_instance(component_definition,transformation)
          g1ents.add_line([0,0,0],[1,1,1])
          # this adds a component, then an edge...
          # you can even add a group inside a group thus...
          g2 = g1ents.add_group
          triangle_face= g2.entities.add_face([0,0,0],[1,0,0],[0,1,0])
          # etc etc...
          
          

          ...

          TIG

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            How would you add existing geometry to a group though TIG? There is no entities.add_existing_entitiesmethod. or new_ents = entities.copy! or anything.

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

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

              @chris fullmer said:

              How would you add existing geometry to a group though TIG? There is no entities.add_existing_entitiesmethod. or new_ents = entities.copy! or anything.

              model=Sketchup.active_model
              g1=model.active_entities.add_group ### initially empty
              g2=model.entities.add_group(model.selection)
              ### or any other 'list' of miscellaneous geometry,
              ### text, instances, groups, dims etc
              g1.entities.add_group(g2)
              g2.explode ### if required...
              ### misc stuff moved into a group.
              ### I know you can skip making g1 and just use g2
              ### but here g1 is either 'pre-existing' or needed later...
              ### OR
              ### to copy items into a group, rather than move them
              ### into a group you can use...
              g1=model.active_entities.add_group ### initially empty
              g2=model.entities.add_group(model.selection)
              ### as above...
              g3=g2.copy
              g2.explode ### to restore originals back as they were...
              g1.entities.add_group(g3)
              g3.explode ### if required...
              ### more misc stuff copied into a group.
              ### I know you can skip making g1 and just use g2 and g3
              ### but here g1 is either 'pre-existing' or needed later...
              
              

              ...

              TIG

              1 Reply Last reply Reply Quote 0
              • Chris FullmerC Offline
                Chris Fullmer
                last edited by

                So the problem isn't with adding existing geometry to a group, it is with adding geometry to a group that is nested.

                Seems like it should be quite possible then to find all nested components. Then find the deepest one. Then add its existing geometry to a new group created inside the component. Then explode the outer componentinstance. Thanks TIG (again and again and again)

                Chris

                Lately you've been tan, suspicious for the winter.
                All my Plugins I've written

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

                  Adding entities to a definition is bug ridden... you can try...

                  
                  g1=model.active_entities.add_group(model.selection)
                  component=instance.definition
                  g=component.entities.add_group(g1)
                  g.explode
                  g1.explode
                  
                  

                  to give you 'loose' stuff inside the component definition...
                  BUT when it Bug-splats it's NOT my fault !
                  It doesn't work because it's trying to move these grouped entities from their parent - the model - into the definition, which itself is another 'parent'. You CAN add new geometry or a group into a definition, BUT then to do that you need to add each of these bits as brand-new geometry. It would be possible to 'copy the info' of each of the group's entities as base-level entities and then recreate them inside the definition bit-by-bit, and at the end you can delete the original items since they are 'moved' into the definition... However, that's a pretty complex task... Info for every group, mining down into it's components, then info for each face, its edges, its materials, its layer etc etc...
                  We need a 'definition.entities.adopt(array_of_another_parents_entities)' method to transfer to another 'parent' ? I don't have time to do it right now - has anyone go one ???
                  ...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • M Offline
                    Matt666
                    last edited by

                    ... Google? πŸ˜„

                    Frenglish at its best !
                    My scripts

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

                      Work around...

                      I've go a half-baked script that might work. I'll post it in a separate thread soon...
                      ...

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • M Offline
                        Matt666
                        last edited by

                        Aaah... Cool!

                        Frenglish at its best !
                        My scripts

                        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