Hi Dan,
@dan rathbun said:
Yes they are.. you just do not realize it yet.
I do realize that. But the script I'm writing is for internal use. So everything
this script will process meets the criteria already. But you couldn't know that..
By the way ' outer_shell
' is also available in free version, I think.
The reason for adding the groups to an array is also clear to me now, otherwise the iteration process is not going well and SU could skip a few items.
Now for the real problem:
First I need to add all the candidates for the boolean unite operation to an array. In other words: only group-entities that intersect will be processed.
I tried BoundingBox.intersect
but it gives me false positives in cases of close
proximity. So I've done some more reading and I ended up in the loops section of the SU API. Can the loop class help me here tot detect if groups really intersect??
This is the only problem left, the boolean problem I solved by my self. This script unifies all intersecting groups to one solid:
<span class="syntaxdefault"> file </span><span class="syntaxkeyword">=</span><span class="syntaxstring">"D;\\Desktop\\bool.skp"<br /></span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">open_file</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">file</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> <br /> model </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br /> entities </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_entities <br /> <br /> foo</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> nonfoo </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[],</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[]<br /></span><span class="syntaxdefault"> grps </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">find_all </span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">ent</span><span class="syntaxkeyword">|</span><span class="syntaxdefault"> ent</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">Group</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> <br /> grps</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">a</span><span class="syntaxkeyword">|</span><span class="syntaxdefault"> unless a </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> grps</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">last <br /> a</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">name </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'foo'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">;</span><span class="syntaxdefault"> foo</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">push a<br /> else<br /> a</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">name </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'nonfoo'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">;</span><span class="syntaxdefault"> nonfoo</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">push a<br /> end <br /> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> <br /> until foo</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> nil<br /> foo</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">ff</span><span class="syntaxkeyword">|</span><span class="syntaxdefault"> <br /> if </span><span class="syntaxkeyword">((</span><span class="syntaxdefault">ff</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">bounds</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">intersect</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">nonfoo</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">bounds</span><span class="syntaxkeyword">)).empty?</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> false<br /> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">ff</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">outer_shell</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">nonfoo</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">])).</span><span class="syntaxdefault">name </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'nonfoo'<br /></span><span class="syntaxdefault"> end<br /> <br /> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> foo </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">find_all </span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">ent</span><span class="syntaxkeyword">|</span><span class="syntaxdefault"> ent</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">name </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> </span><span class="syntaxstring">'foo'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> <br /> nonfoo </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">find_all </span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">ent</span><span class="syntaxkeyword">|</span><span class="syntaxdefault"> ent</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">name </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> </span><span class="syntaxstring">'nonfoo'</span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> <br /> end</span>
bool.skp