You helped me a lot! Thanks!!!!
Now, my current (but not yet perfectly working result):
<span class="syntaxdefault">group </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> projectGroup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_group<br /><br /></span><span class="syntaxcomment"># add selected faces to group<br /></span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">selection</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each do </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">tmp</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault"> if tmp</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">ComponentInstance</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">||</span><span class="syntaxdefault"> tmp</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">)<br /></span><span class="syntaxdefault"> getEntities</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">tmp</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> nil</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> group</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> elsif tmp</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"> newFace </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> tmp</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">copy</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> nil</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> end<br />end</span>
<span class="syntaxdefault"></span><span class="syntaxcomment"># Thanks to http://sketchucation.com/forums/viewtopic.php?f=180&t=29138&start=0<br /></span><span class="syntaxdefault">class Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Face<br /> def copy</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">ents</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> trans</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> vec </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Vector3d</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">new 0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">0<br /> dist </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 0<br /><br /> ov</span><span class="syntaxkeyword">=[]<br /></span><span class="syntaxdefault"> vec</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> dist if dist </span><span class="syntaxkeyword">!=</span><span class="syntaxdefault"> 0<br /> self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">outer_loop</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">vertices</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each do </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">v</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault"> if dist </span><span class="syntaxkeyword">!=</span><span class="syntaxdefault"> 0<br /> ov</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">push</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">v</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">offset</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">vec</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault"> else<br /> if </span><span class="syntaxkeyword">(!</span><span class="syntaxdefault">trans</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">?)<br /></span><span class="syntaxdefault"> ov</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">push</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">v</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transform</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">trans</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault"> else<br /> ov</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">push</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">v</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> end<br /> end<br /> end<br /> outer_face </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> ents</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_face ov<br /> outer_face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">material </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"green"<br /><br /></span><span class="syntaxdefault"> inner_faces </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">[]<br /></span><span class="syntaxdefault"> if self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">loops</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length </span><span class="syntaxkeyword">></span><span class="syntaxdefault"> 1<br /> il </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">loops<br /> il</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">shift<br /> il</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each do </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">loop</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault"> ov</span><span class="syntaxkeyword">=[]<br /></span><span class="syntaxdefault"> loop</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">vertices</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each do </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">v</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault"> if dist </span><span class="syntaxkeyword">!=</span><span class="syntaxdefault"> 0<br /> ov</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">push</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">v</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">offset</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">vec</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault"> else<br /> if </span><span class="syntaxkeyword">(!</span><span class="syntaxdefault">trans</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">?)<br /></span><span class="syntaxdefault"> ov</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">push</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">v</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transform</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">trans</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault"> else<br /> ov</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">push</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">v</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">position</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> end<br /> end<br /> end<br /> inner_face </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> ents</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_face ov<br /> inner_faces</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">push</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">inner_face</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> end<br /> inner_faces</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each do </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">f</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault"> f</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">erase</span><span class="syntaxkeyword">!<br /></span><span class="syntaxdefault"> end<br /> end<br /> return outer_face<br /> end<br />end </span><span class="syntaxcomment"># Class Face </span><span class="syntaxdefault"></span>
<span class="syntaxdefault">def getEntities</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">element</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> trans</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> group</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> entitiesArray </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Array</span><span class="syntaxkeyword">.new()<br /><br /></span><span class="syntaxdefault"> if </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">element</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">ComponentInstance</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault"> elementEnts </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> element</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">definition<br /> else<br /> elementEnts </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> element<br /> end<br /><br /> elementEnts</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each do </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">entity</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault"> if 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">ComponentInstance</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">||</span><span class="syntaxdefault"> 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">Group</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> if </span><span class="syntaxkeyword">(!</span><span class="syntaxdefault">trans</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">?)<br /></span><span class="syntaxdefault"> trans </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> trans </span><span class="syntaxkeyword">*</span><span class="syntaxdefault"> entity</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transformation<br /> else<br /> trans </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> entity</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transformation<br /> end<br /> getEntities</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">entity</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> trans</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> group</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> elsif 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"> newFace </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> entity</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">copy</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> trans</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> end<br /> end<br />end</span>
Oh my goodness - lots of stuff
So, copying all the faces into the group "group" is successful. Problem: At the end, the position of "group" is different then the original one... so, the transformation doesn't work.
Do you understand my Ruby code and, with a little bit of luck - can you find a mistake using the transformation? I'm not quite sure about
trans = trans * entity.transformation
Thanks again for all your help!!!
EDIT: Oh, why the tabs in the code are not shown? Now, the code looks not very clear...