Hope someone finds these useful, I use it to record a point cloud via a webcam for digitising parts.
The result all comes down to how good your camera setup is, how you deal with paralax etc but I have some pretty good results.
The output is a CSV wich I read into CamBam, my choice of design software.
Enjoy
Macro #1
Clear out the previous file
This could be added as a dialouge to Macro #2, I just haven't bothered.
- Code: Select all
#VB
Dim filePath As String = "c:\UCCNC\dxf.txt"
If System.IO.File.Exists(filePath) Then
Dim confirm As DialogResult = MessageBox.Show("Are you sure you want to delete the previous file?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
If confirm = DialogResult.Yes Then
System.IO.File.Delete(filePath)
MessageBox.Show("File deleted successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Else
MessageBox.Show("File does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Macro #2
Write a series of DRO positions to a CSV file
Use your webcam to hover over a point and record that DRO position to make a point cloud later
Make a new button on your screenset and just click it every time you want to record a point.
- Code: Select all
#VB
Dim Xpos As Double = exec.GetXmachpos() ' Get the current machine coordinates
Dim Ypos As Double = exec.GetYmachpos() ' Get the current machine coordinates
Dim filePath As String = "C:\UCCNC\DXF.txt" 'Change this as suits your System
DIM pointmessage As String = "The data point values are X="& Xpos &" & Y="& Ypos
Dim file As System.IO.StreamWriter
MessageBox.Show(pointmessage)
file = My.Computer.FileSystem.OpenTextFileWriter(filePath, True)
file.WriteLine(Xpos & "," & Ypos &",0") 'Appended a trailing zero so CamBam will accept this as a valid point list file
file.Close()
Macro #3
Jog your machine to a pre-planned offset based on your webcam
- Code: Select all
Code:
/* M120001
Jog to bottom left corner of part after Camera alignment
*/
double FR = 1000; // sets Feedrate
double DT = 3000; // Sets Dwell Time (mSec, 3000 = 3 sec)
DialogResult result;
Console.Beep();
Console.Beep();
Console.Beep();
result = MessageBox.Show("Is Your Z HEIGHT Safe To Travel?", "check!!!" , MessageBoxButtons.YesNo);
if (result == System.Windows.Forms.DialogResult.Yes)
{
exec.Code("G92 X0 Y0"); // Zero the X & Y DRO's
exec.Code("G01 X-166.60"+ "Y101.40" + " F" + FR); // Move to the camera offset co-ords
while(exec.IsMoving()){}
exec.Wait(200);
exec.Code("G92 X0 Y0"); // Zero the X & Y DRO's
MessageBox.Show("Tool is now aligned to the corner of the work");
Console.Beep();
}
if (result == System.Windows.Forms.DialogResult.No)
{
MessageBox.Show("Move Z To A Safe Position And Restart");
}