Deleting group.copy?
-
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.
-
group.erase!
-
@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.
-
@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!
-
You can access any face's attributes whether or not it's inside a group ??
I fail to understand you fully. -
@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"># Read group attributes<br /></span><span class="syntaxdefault">x </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_attribute</span><span class="syntaxkeyword">( </span><span class="syntaxstring">'Foo'</span><span class="syntaxkeyword">, </span><span class="syntaxstring">'Bar' </span><span class="syntaxkeyword">)<br /></span><span class="syntaxcomment"># Read attributes from faces inside<br /></span><span class="syntaxkeyword">for </span><span class="syntaxdefault">entity in group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities<br /> next unless entity</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">is_a</span><span class="syntaxkeyword">?( </span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Face </span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">x </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">entity</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_attribute</span><span class="syntaxkeyword">( </span><span class="syntaxstring">'Foo'</span><span class="syntaxkeyword">, </span><span class="syntaxstring">'Bar' </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.)
-
That may just work. And I figured out why I can't erase the group.copy - because I exploded it. Sometimes I feel dumb.
-
Yeah, that worked, and not having to explode my group fixed a lot of problems. Thank you!
Advertisement