Hello Guest it is April 26, 2024, 06:36:14 PM

Author Topic: How to change axis position in a script?  (Read 352 times)

0 Members and 1 Guest are viewing this topic.

How to change axis position in a script?
« on: April 25, 2023, 09:57:44 PM »
I'm just starting to learn how to write some scripts and want to make a simple button to change the x axis position with a script like when you click on the x dro and change the position with the keypad.
I used scr.SetProperty("droCurrentX","Value",regval) to set the dro but as soon as I move the axis it reverts back to the original position before I changed it.
What command should I use to do this?
Thanks
Re: How to change axis position in a script?
« Reply #1 on: April 25, 2023, 11:50:47 PM »
Hi,

Quote
I used scr.SetProperty("droCurrentX","Value",regval) to set the dro but as soon as I move the axis it reverts back to the original position before I changed it.
What command should I use to do this?

That is incorrect. The numeric value displayed in a DRO is just the visual artefact that results from displaying the true internal value. For instance lets assume the X axis
position is x=123.456. You come along blithely and set the DRO to 654.321, but the true and underlying value remains 123.456, and therefore at the next screen re-draw
the DRO again displays that true and underlying value.

The machine coordinates of the current location of the machine are determined by the distance from the Home point or Reference point and the machine position.
The only way to change the machine coordinates to some other value is to shift the machine......end of story. Work coordinates can be changed however.
The commonly displayed axis position  is = machine coordinate (of that axis)  - WorkOffset (of that axis). You can change the WorkOffset with Gcodes or with a script.

This concept is hard for most people to grasp......you cannot set a machine coordinates at will. The only way to set a machine coordinate is by using one of the Homing procedures.
There is s trick means of doing so by using the HomeInPLace function......but its confusing....and ultimately counterproductive. I tried using it years ago...and it worked
but actually caused me more grief than it was supposed to solve.

By the way, this API works by changing the WorkOffset....not as most people assume by changing the machine coordinate:

Code: [Select]
LUA Syntax:
rc = mc.mcAxisSetPos(
number mInst,
number axisId,
number val);

Description:
Set the Position of an axis by changing the fixture offset.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: How to change axis position in a script?
« Reply #2 on: April 26, 2023, 07:51:03 AM »
Yes, I did find after a lot of searching - mc.mcAxisSetPos(inst, mc.X_AXIS,7).  That is what I was trying to do.
The big question is, is there a reference manual with all these mach4 terms and what they do? I have not been able to find anything yet. There must be something somewhere.

I did find Mach4EnumsList2.txt which does show a bunch of these but not too much of what they are.
Thanks
« Last Edit: April 26, 2023, 08:00:15 AM by daseitz »

Offline Bill_O

*
  •  563 563
    • View Profile
Re: How to change axis position in a script?
« Reply #3 on: April 26, 2023, 12:38:40 PM »
daseitz,

They are in the c:\Mach4Hobby\Docs\Mach4CoreAPI.chm
Re: How to change axis position in a script?
« Reply #4 on: April 26, 2023, 01:02:13 PM »
Thank you