Hello Guest it is March 28, 2024, 03:59:54 PM

Author Topic: Toggle Machine Coordinates from a script  (Read 669 times)

0 Members and 1 Guest are viewing this topic.

Toggle Machine Coordinates from a script
« on: February 13, 2020, 01:06:10 PM »
Sorry to keep asking...the lack of documentation makes this stuff pretty frustrating.  I really appreciate your help!  Thank you!

So, I've been doing a lot of digging, but not found a solution.  I want to make sure I am in in Machine Coordinates modes and that the DRO's display machine coords before I start a procedure.  I can check the state using OSIG_MACHINE_CORD and that works.  But how to toggle the,m if they are on Work Coordinates?  Back to my VB days, I thought I'd just click the button but I read that is not a good method and I couldn't get it to work. 

In my playing, I found that the Machine Coordinates On action doesn't work?  Off works and Toggle works, but On doesn't.  Wasn't sure how to do that from the script anyway. 

Any ideas?  Do I need to change the signal?  Will that toggle the screen DRO's and button?  I haven't tried that sort of thing yet.

Tony
This seems to work...
« Reply #1 on: February 13, 2020, 02:35:54 PM »
Looks like when the machine coords signal is changed, the toggle button and dro's are toggled as well.  So I think this will do what I want.  It seems to work.  How exciting!

Code: [Select]
--attempt to check state of machine coords and change to machine coords if they are not
--already 1=true = machine  0 = false = work

local inst = mc.mcGetInstance()
local hsig = mc.mcSignalGetHandle(inst, mc.OSIG_MACHINE_CORD)
local sig = mc.mcSignalGetState(hsig)

if (sig == 0) then
mc.mcSignalSetState(hsig,1)
end