Misbehavior when work axes have been moved/rotated
-
I've noticed that one of my scripts is misbehaving when the axes tool have been used to move the work axes.
Is there a way of determining if the axes been moved and get the new axis? -
The Axis is not exposed in the Ruby API,... yet.
Not sure if ThomThom found a workaround, ya might check his GitHub page.
-
Not what I had hoped for but thanks for the answer. I will check with Thomthom also.
-
The API currently lacks support for getting the current working axes.
I've used a hacky workaround in the past involving creating temp groups to extract the info - I need to dig around to find where I'd used that. -
That would be great.
-
NOTE! THIS IS A DIRTY HACK!
Avoid if possible.
DO NOT use in the middle of another operation or observer event!
It creates a couple of temp groups and extract the axes information from that. This works because since SU7 groups orient themselves by the working axes.
If you absolutely need to use this within another operation then remove the start/abort_operation and manually remove the temp group.
Note that you only get the orientation of the axes - not the position because for some reason the transformation return bogus values for the origin.
<span class="syntaxdefault"><br /> </span><span class="syntaxcomment"># SU7+ only - incorrect in older versions.<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># A hack to get the current model axis.<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># @return [Array<Vector3d,Vector3d,Vector3d>]<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># @since 1.1.0<br /></span><span class="syntaxdefault"> def get_local_transformation<br /> </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start_operation</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'Get Local Transformation (Hack)'</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> entities </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_entities<br /> tr </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_group</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_group</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">transformation<br /> </span><span class="syntaxcomment"># (?) SketchUp bug?<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># The transformation returned has X, Y and Z set to 1.0e+030!<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># Why this high value? Overflow bug?<br /></span><span class="syntaxdefault"> Geom</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Transformation</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault"> tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">xaxis</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">yaxis</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> tr</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">zaxis</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> ORIGIN </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> ensure<br /> </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">abort_operation<br /> end<br /></span>
-
Big thanks.
I will try this.
I think I only need the orientation.
Advertisement