@tig said:
Gai's link is to fix components.
The default axes [aka origin or insertion-point] of a group [or component] always go at its geometry's bounds.min corner [bottom-left-front].
If you want them to be at the model's ORIGIN for a group you must include something at the origin as you can't change a group's axes through the context-menu [unlike with a component].
It is possible to code something to reset groups' axes to the model's ORIGIN...
<span class="syntaxdefault">module TIG<br /> def TIG</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">originateselectedgroups</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br /> ss</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">selection<br /> return nil unless ss</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start_operation</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"TIG.originateselectedgroups"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> ss</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">gp</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault"> next unless gp</span><span class="syntaxkeyword">.class==</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Group<br /> gp</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">make_unique </span><span class="syntaxcomment">### forced - deprecated messages are API error!<br /></span><span class="syntaxdefault"> gents</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">gp</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities<br /> tr</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Transformation</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">translation</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">gp</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transformation</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">origin</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">vector_to</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">ORIGIN</span><span class="syntaxkeyword">))<br /></span><span class="syntaxdefault"> gp</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transform</span><span class="syntaxkeyword">!(</span><span class="syntaxdefault">tr</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> gents</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">transform_entities</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">inverse</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> gents</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_a</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">commit_operation<br /> end<br />end</span>
Put all of this into a plain text file file in the Plugins folder named say ' TIG-originateselectedgroups.rb'. Restart Sketchup so it auto-loads.
Select some stuff including some groups and type in the Ruby Console:
TIG.originateselectedgroups
All groups will have their axes relocated at the ORIGIN.
Nested groups locate at the container's origin - which will be the ORIGIN, IF the container was processed earlier...
Ignore the make_unique error messages, you can't have duplicate groups and hope for them to both be right [Bugsplat!], so it forces all groups to become 'unique'.
🤓
TIG! Thank you so much for this.
Would it be possible to have the same function done for both components and groups?
I tried mixing the code, but my thin knowledge in programming doesn't cut it!
Also, would it be possible to target all nested components and groups?