Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: DAAD on November 19, 2020, 07:31:31 AM
-
At the moment i have a probe height point on my table to setup quickly correct height of my tools.
But if i flycut my table, i need to adjust the value into my module each time.
Would there be a way to put a field inside my screenset where i can put the value into so that my module can pick it up?
It would save me some hassle of editing the module each time.
Keep Safe,
Adam
-
Yes. See bryanna's video on screen set editing. Add a dro where you want and name it. in the events for that dro either update a register that you create or write the value to a profile string. In the startup script or in the macro read either the register or the profile value.
HTH
RT
-
thanks, will study the vid this weekend!
-
I'm still learning to get on with lua...
I, was able to make an dro to put in a value.
But when i close the program i lose the Number
Here is what i did load into the screen load script:
--local inst = mc.mcGetInstance()
local droVal = mc.mcProfileGetInt(inst, "Preferences", "ToolSetHeigth", 0)
scr.SetProperty("droToolset", "Value",tostring(droVal))
And here is what i put in the unload script:
--Save dro Toolsetter Height to .ini
local droVal = scr.GetProperty('droToolset','Value')
mc.mcProfileWriteString(inst, "ToolSetHeigth","MachineBedOffset", droVal)
If i look into the ini file i can't seem to find back the info that schould have been written...
If i can load unload the dor i can use it to get data in an lua module i use.
Adam
-
You are writing the value to one place "ToolSetHeigth","MachineBedOffset" and then reading it from somewhere else "Preferences", "ToolSetHeigth". Make these the same and it should work
-
I've made an error while pasting the code.
I've double checked, my code and both parameters are the same.
Still not saving the dro when i close and open mach 4...
-
Is it saving the value correctly in the screen unload portion? You could check by looking in the actual Machine.ini file after you've closed Mach4.
If it is saving the value correctly, but not loading it, then I'd try moving the code that's in your screen load script to the portion of the PLC script that only executes on the first run. At the bottom of the PLC script, I think there's a comment that says "PLC First Run".
Sometimes all the screen elements aren't loaded yet if you try to change their values in the screen load script.
-
Hello,
Thanks for the tip,
Searched the ini file and no parameter or value is saved...
I've double checked the spelling of the dro and all seems correct.
do i need to do something specific for saving the data to the ini file?
-
rc = mc.mcProfileFlush(number mInst)
rc = mc.mcProfileSave(number mInst)
I see you are saving the value as a string and then reading it back as an int but setting the value of the DRO as a string.
Have you checked the droVal returned by the getProperty? Is it a string or a number?
I think the preferred method is to not write to the profile but to create gReg entry (Config->Plugins->RegFile, Global Registers Tab) and mark it as persistent. It will be read and saved automatically and you can access its value as needed. Set the 'Register' property of the DRO to be that variable.
HTH
RT
-
rc = mc.mcProfileFlush(number mInst)
rc = mc.mcProfileSave(number mInst)
I see you are saving the value as a string and then reading it back as an int but setting the value of the DRO as a string.
Have you checked the droVal returned by the getProperty? Is it a string or a number?
I think the preferred method is to not write to the profile but to create gReg entry (Config->Plugins->RegFile, Global Registers Tab) and mark it as persistent. It will be read and saved automatically and you can access its value as needed. Set the 'Register' property of the DRO to be that variable.
HTH
RT
The above with the registers worked perfectly!
Thanks!