3 Replies Latest reply on Jan 4, 2016 9:56 PM by james.dickson

    how do i find the X Y location of where the cursor snaps to?

    james.dickson

      Hi,

      I am trying to write a script for expedition that uses motionGfx and events to draw objects on the screen. I want to use it with the snap points on an object when the hoover snap is turned on, but event commands such as

           _OnMouseClk(button, flags, dx, dy)

      i think only returns the mouse position, not the snap location.

      I noticed you can use command like .MotionGfxPutLine(....) with epcbMotionGfxPointType set to epcbMotionGfxPointMoveXY will snap to the snap location, but i don't think there is any way to return that position.

       

      Is there anyway to return the location of the currently highlighted snap point?

       

      Thanks,

      James

        • 1. Re: how do i find the X Y location of where the cursor snaps to?
          kendall_hiles

          James;

           

          What is the use case.  In AATK we use motion graphics and snap points, if you explain what your doing, I may be able to point you to a script that does something similar.

          • 2. Re: how do i find the X Y location of where the cursor snaps to?
            james.dickson

            Hi Kendall,

            I want to make a better measurement tool which shows both at the same time  mm and mils units. I also want to be able to measure parallel distance between object which are on 45 degrees.

            • 3. Re: how do i find the X Y location of where the cursor snaps to?
              james.dickson

              I found the solution.

              There is a hidden property called 'snaplocation'

               

              Property SnapLocation(Event As EPcbEventTypeCmd, [button As EPcbMouseButton = epcbMouseButtonLeft]) As Boolean

                  Member of MGCPCB.Command

                  Snaps the location for the specified event when snapping is enabled. Only valid for the button down, button click, and mouse move events.

               

              EPcbEventTypeCmd options are:

                epcbEventCmdOnChar

                epcbEventCmdOnLayerChanged

                epcbEventCmdOnMouseBeginDrag

                epcbEventCmdOnMouseCancelDrag

                epcbEventCmdOnMouseClk

                epcbEventCmdOnMouseDblClk

                epcbEventCmdOnMouseDown

                epcbEventCmdOnMouseDrag

                epcbEventCmdOnMouseEndDrag

                epcbEventCmdOnMouseMove

                epcbEventCmdOnTerminate

                epcbEventCmdOnUndo

                epcbEventCmdOnVChar

               

              EPcbMouseButton options are:

                epcbMouseButtonLeft

                epcbMouseButtonMiddle

                epcbMouseButtonRight

               

              To use this you need to register the command, attach it and then set this snaplocation to true.

              In this example i used the epcbEventCmdOnMouseMove and the corresponding OnMouseMove event.

              When the mouse moves the dX and dY variables use the snap location

                'example on how to use snap location.

                Set ccmd = app.Gui.RegisterCommand("my command", True)

                Call Scripting.AttachEvents(ccmd, "ccmd")

                ccmd.SnapLocation(epcbEventCmdOnMouseMove)=true

               

                 Function ccmd_OnMouseMove(eButton, eFlags, dX, dY)

                   Call app.Gui.StatusBarText("x="& dX &" y=" & dY , epcbStatusField3)

                 End Function

               

              It would have been nice to see this in the automation documentation.