sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Misbehavior when work axes have been moved/rotated

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 413 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PixeroP Offline
      Pixero
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        The Axis is not exposed in the Ruby API,... yet.

        Not sure if ThomThom found a workaround, ya might check his GitHub page.

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • PixeroP Offline
          Pixero
          last edited by

          Not what I had hoped for but thanks for the answer. I will check with Thomthom also.

          1 Reply Last reply Reply Quote 0
          • tt_suT Offline
            tt_su
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • PixeroP Offline
              Pixero
              last edited by

              That would be great.

              1 Reply Last reply Reply Quote 0
              • tt_suT Offline
                tt_su
                last edited by

                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>
                
                1 Reply Last reply Reply Quote 0
                • PixeroP Offline
                  Pixero
                  last edited by

                  Big thanks.
                  I will try this.
                  I think I only need the orientation. 👍

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  Buy SketchPlus
                  Buy SUbD
                  Buy WrapR
                  Buy eBook
                  Buy Modelur
                  Buy Vertex Tools
                  Buy SketchCuisine
                  Buy FormFonts

                  Advertisement