Hello Guest it is April 26, 2024, 09:13:02 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - thespindoctor

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 »
81
Fantastic!  Thanks so much. I will study.  I am sure others will be helped as well.

82
Thanks Craig, I have done the same thing.  It is very helpful.   Thatt and stealing the wx.messagebox is about the exrent of my widgets prowess!

83
Reinhard, Thanks for the warning!  Don't worry, I am using the Api for ini and reg file access.  Only using direct file io for .txt and .csv files.

Thanks
Keith

84
Probably could open the probe file directly but was trying to learn general file i/o opreations.

Just had some success with regfile entries now on to .ini file work.  Gradually getting the hang of Lua and a little wx.wizards

Lots of trial and error and wx.messagebox to see what happened. 

Found a book about widgets on Amazon that might help because the docsare too difficukt for me.

Thanks!

85
working now not sure what I did to make it go

using the wx.wxGetCwd as listed and it gave the proper directory and file however at first it did not.  Crazy\

Thanks

86
New verion...

Code: [Select]

local ProbeYWheel={}
local inst = mc.mcGetInstance()

local CSVPath= wx.wxGetCwd() .. "\\GcodeFiles\\KFCProbeWheelFLAT.csv" --1 line .csv file with x,y,z position from probing one time

--open file and read out the data

io.input(io.open(CSVPath, "r"))

local line;
for line in io.lines(CSVPath) do
tkz=wx.wxStringTokenizer(line,",");
ProbeYWheel[1]={}--make blank table to hold the data
local token=tkz:GetNextToken();

ProbeYWheel[1] ["X_Position"]=token;
ProbeYWheel1] ["Y_Position"]=tkz:GetNextToken();
ProbeYWheel[1] ["Z_Position"]=tkz:GetNextToken();
end
io.close()

--read data
local XPos = ProbeYWheel[1].X_Position
local YPos = ProbeYWheel[1].Y_Position
local ZPos = ProbeYWheel[1].Z_Position

    mc.mcCntlSetLastError(inst,string.format(" X: %.4f | Y: %.4f | Z: %.4f", XPos, YPos, ZPos))


87
Yes that is a good pickup on the Token vs token, thanks I missed it.

Does the line for file path seem ok?  It cannot get anything but a nil.

Trying to use the debugger for the first time, I think it will help very much.

Thanks for responding!

Keith

88
Mach4 General Discussion / Re: more lua (?) questions
« on: May 08, 2017, 09:25:48 AM »
Glad you have posted this bacause I need thus capability for my system but still stuck on the basics of file i/o and table manipulation.
Danke fiel mals again!
Keith

89
seems like the position should be 0 for the first line in the file and 0 for position in the array?

Code: [Select]

--program to retrieve one line of probe data from a prob file
--and display the x,y,z positions in the error line
-- it does not seem to work and I am not sure why


local ProbeYWheel={}
local inst = mc.mcGetInstance()

local CSVPath= wx.wxGetCwd() .. "\\GcodeFiles\\KFCProbeWheelFLAT.csv"
--open file and read out the data
io.input(io.open(CSVPath, "r"))
local line;
for line in io.lines(CSVPath) do
tkz=wx.wxStringTokenizer(line,",");
ProbeYWheel[0]={}--make blank table to hold the data
local token=tkz:GetNextToken();

ProbeYWheel[0] ["X_Position"]=Token;
ProbeYWheel[0] ["y_Position"]=tkz:GetNextToken();
ProbeYWheel[0] ["Z_Position"]=tkz:GetNextToken();
end
io.close()

--read data
local XPos = ProbeYWheel[0].X_Position
local YPos = ProbeYWheel[0].Y_Position
local ZPos = ProbeYWheel[0].Z_Position

    mc.mcCntlSetLastError(inst,string.format(" X: %.4f | Y: %.4f | Z: %.4f", XPos, YPos, ZPos))


90
I have probed a single surface and am able to get x,y,z positions stored in a probe file.  The next step is to be able to read this one line .csv file and retrieve the x,y,z values.  Other ways to handle the information would be writing registers and then saving to the .ini file or obtaining the variable 5071,5072, and 5072.  i would like to learn to work with the file operations at this point.  Of course the Lua learning curve is still holding me down but I have been able to cut and paste and make a lot of progress.  Properly getting the path listed and working with tables is tricky.   I though I was understanding how it is done but no joy.  The code posted here seems correct to me but it is providing a nil value for the CSVpath to start with.  This is about as simple as it gets and I can't get it done...
Thanks for any suggestions.

Keith
Code: [Select]
--program to retrieve one line of probe data from a prob file
--and display the x,y,z positions in the error line
-- it does not seem to work and I am not sure why

local ProbeYWheel={}
local inst = mc.mcGetInstance()

local CSVPath= wx.wxGetCwd() .. "\\GcodeFiles\\KFCProbeWheelFLAT.csv" --1 line .csv file with x,y,z position from probing one time

--open file and read out the data

io.input(io.open(CSVPath, "r"))

local line;
for line in io.lines(CSVPath) do
tkz=wx.wxStringTokenizer(line,",");
ProbeYWheel["0"]={}--make blank table to hold the data - Should this be "0"??
local token=tkz:GetNextToken();

ProbeYWheel["0"] ["X_Position"]=Token; --i assume the first line is line 0??
ProbeYWheel["0"] ["y_Position"]=tkz:GetNextToken();
ProbeYWheel["0"] ["Z_Position"]=tkz:GetNextToken();
end
io.close()

--read data
local XPos = ProbeYWheel["0"].X_Position --should this be "0" ??
local YPos = ProbeYWheel["0"].Y_Position
local ZPos = ProbeYWheel["0"].Z_Position

    mc.mcCntlSetLastError(inst,string.format(" X: %.4f | Y: %.4f | Z: %.4f", XPos, YPos, ZPos))


Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 »