sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Deleting group.copy?

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 3 Posters 212 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.
    • L Offline
      lothcat
      last edited by

      I am having a hard time figuring out how to delete a group. I'm making a copy of a group to explode it and look at the faces, because I want to keep the original group intact, and then when I'm done with the copy, I want to get rid of it.

      Here's my code:

           if entity.typename == "Group"
      	 #UI.messagebox "Group!"
               copy_group = entity.copy
      		 status = copy_group.explode
      		 facecounter(status)
      

      I tried using entities.erase_entities copy_group where entities = Sketchup.active_model.active_entities, but that didn't work, so now I'm wondering if there's a better way.

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

        group.erase!

        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

          @lothcat said:

          I'm making a copy of a group to explode it and look at the faces

          What do you mean by this? "Look at the faces"? I'm wondering why you are making seemingly temp groups to inspect something.

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

          1 Reply Last reply Reply Quote 0
          • L Offline
            lothcat
            last edited by

            @thomthom said:

            What do you mean by this? "Look at the faces"? I'm wondering why you are making seemingly temp groups to inspect something.

            I have attributes attached to the faces that I need to read, but I also have attributes attached to the group. If I don't explode the group, I can't get to the attributes in the face, but if I do explode the group, I lose the group attributes.

            Probably not the best way to do it, but it works.

            And thank you for the help!

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

              You can access any face's attributes whether or not it's inside a group ??
              I fail to understand you fully. πŸ˜•

              TIG

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

                @lothcat said:

                If I don't explode the group, I can't get to the attributes in the face

                You can access any entity within any context (group/component) at any time.

                I think it's best here to go back a step and look at what you try to do.

                <span class="syntaxdefault"><br /></span><span class="syntaxcomment">#&nbsp;Read&nbsp;group&nbsp;attributes<br /></span><span class="syntaxdefault">x&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_attribute</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxstring">'Foo'</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxstring">'Bar'&nbsp;</span><span class="syntaxkeyword">)<br /></span><span class="syntaxcomment">#&nbsp;Read&nbsp;attributes&nbsp;from&nbsp;faces&nbsp;inside<br /></span><span class="syntaxkeyword">for&nbsp;</span><span class="syntaxdefault">entity&nbsp;in&nbsp;group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities<br />&nbsp;&nbsp;next&nbsp;unless&nbsp;entity</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">is_a</span><span class="syntaxkeyword">?(&nbsp;</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Face&nbsp;</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">x&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">entity</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_attribute</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxstring">'Foo'</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxstring">'Bar'&nbsp;</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">end<br /></span>
                

                Maybe we should step back even further and ask why you are using attributes? (Just in case there is another way for what you want to do.)

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

                1 Reply Last reply Reply Quote 0
                • L Offline
                  lothcat
                  last edited by

                  That may just work. And I figured out why I can't erase the group.copy - because I exploded it. Sometimes I feel dumb.

                  1 Reply Last reply Reply Quote 0
                  • L Offline
                    lothcat
                    last edited by

                    Yeah, that worked, and not having to explode my group fixed a lot of problems. Thank you!

                    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