Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Bodini on May 09, 2014, 10:23:08 AM

Title: Lua: ? How to set a DRO that has a "DRO Code" ?
Post by: Bodini on May 09, 2014, 10:23:08 AM
I am trying to set a DRO that has a "DRO Code" from the drop down in its Properties... such as "xdro1" on the default screen. (In Mach3/VB this would be like a "SETOEMDRO" if I remember correctly.)

Used the code "scr.SetProperty('xdro1', 'Value', tostring("999"))" and it works for a millisecond (you can see it flash by in the DRO).  But then the Value goes back to what it was before the DRO was set.

I notice that when the "DRO Code" is cleared, this doesn't happen.  Obviously there is another part of the process that I am unaware of.  Please advise!

Also just noticed that it works when the screen is being edited.  So, I'd guess this is some sort of PLC script issue or something like that.
Title: Re: Lua: ? How to set a DRO that has a "DRO Code" ?
Post by: Overloaded on May 09, 2014, 11:15:05 AM
Not sure of this, but did you check out Poppa's list ?

http://www.machsupport.com/forum/index.php/topic,27141.0.html

mc.mcAxisSetPos(number mInst, number axis, number val)

Just guessing till help comes along,
Russ

Title: Re: Lua: ? How to set a DRO that has a "DRO Code" ?
Post by: Bodini on May 09, 2014, 01:00:28 PM
OK thanks.  I did see that list but did not realize the application as related to my question.  Yep, that works.
Title: Re: Lua: ? How to set a DRO that has a "DRO Code" ?
Post by: smurph on May 09, 2014, 02:49:30 PM
Russ is correct.  If you have a DRO that has a code assigned, it can only be updated with a mc.mc* API call and not using scr.SetProperty().  This is because that DRO is getting updated every screen refresh from the code assigned to it.  So you have to modify what is driving the DRO instead.  Take the Zero X button.  It is actually calling mcAsixSetPos() behind the scenes to modify the X axis DRO.