A nearby Community College has a Romer absolute arm that has been setting unused for several years. I recently retired from an engineering career and have volunteered to get the arm up and running so the students can learn some basic concepts about CMM. The school has lost their USB key license for the PC-DMIS software and it will be several months before they look at budgets and getting the software might not make the cut.
I would like to get something very basic going just so the students can try the arm. My thought was to create a simple script that would allow the student to digitize several points and then save them to a text file. They could then import those points into their CAD software and generate features off the points. From there they could generate an stl file and print something with their 3D printer. So the lesson would be more related to reverse engineering as opposed to part validation.
A simple script that would just collect a bunch of points seems like it would be easy to create. No need to create any alignments or other features, just capture a series of raw point locations. I've got some experience with programming, but not with DMIS. It would be great if someone had had a script that would do this?
Any help you can provide would be greatly appreciated.
here's my script to CSV export measured values from measured or DCC features including all hit points. Maybe it will help.
Dim PCDapp As Object
Dim PCDpart As Object
Dim Cmds As Object
Dim Cmd As Object
Dim FCmd As Object
Dim fs As Object
Dim oPointData As Object
Dim oHitData As Object
Dim x#, y#, z#, x2#, y2#, z2#, x3#, y3#, z3#
Dim i#, j#, k#, i2#, j2#, k2#
Dim d#, l#, h#, a#, w#
Dim hitXYZ#(3), hitNum%, numhits%
Dim CmdID$, Batch$, Num$, FileTime$, FileName$, FilePath$
Dim Spc$, AlgnID$
Sub Main
Set PCDapp = CreateObject("PCDLRN.Application")
Set oPointData = CreateObject("PCDLRN.PointData")
Set oHitData = CreateObject("PCDLRN.PointData")
Set PCDpart = PCDapp.ActivePartProgram
Set Cmds = PCDpart.Commands
Set fs = CreateObject("Scripting.FileSystemObject")
FilePath = PCDpart.Path & "\data"
If Not(fs.FolderExists (FilePath)) Then
retval = fs.CreateFolder(FilePath)
End If
If Cmd.IsAlignment And Cmd.ID <> "" Then
AlgnID = Cmd.ID
End If
If Cmd.Type = RECALL_ALIGN Then
AlgnID = cmd.GetText(REF_ID, 0)
End If
If Cmd.IsFeature Or Cmd.IsScan Then
If Cmd.ID <> "" Then
If Cmd.IsDCCFeature Or Cmd.IsMeasuredFeature Or Cmd.IsScan Then
CmdID = Cmd.ID
Set FCmd = Cmd.FeatureCommand
retval = FCmd.GetData(oPointData, FDATA_CENTROID, FDATA_MEAS, FDATA_PART, AlgnID, PLANE_TOP)
x = oPointData.X
y = oPointData.Y
z = oPointData.Z
retval = FCmd.GetData(oPointData, FDATA_VECTOR, FDATA_MEAS, FDATA_PART, AlgnID, PLANE_TOP)
i = oPointData.I
j = oPointData.J
k = oPointData.K
Select Case Cmd.Feature
Case F_CIRCLE
d = FCmd.MeasDiam
If FCmd.MeasHeight <> 0 Then
h = FCmd.MeasHeight
End If
Case F_CONE
a = FCmd.MeasAngle
d = FCmd.MeasDiam
l = FCmd.MeasLength
Case F_CYLINDER
d = FCmd.MeasDiam
l = FCmd.MeasLength
Case F_ELLIPSE
l = FCmd.MeasMajorAxis
w = FCmd.MeasMinorAxis
retval = FCmd.GetData(oPointData, FDATA_SLOT_VECTOR, FDATA_MEAS, FDATA_PART, AlgnID, PLANE_TOP)
i2 = oPointData.I
j2 = oPointData.J
k2 = oPointData.K
numhits = FCmd.NumHits
If numhits > 0 Then
For hitNum = 1 To numhits
Set oHitData = FCmd.GetHit(hitNum, FHITDATA_CENTROID, FDATA_MEAS, FDATA_PART, AlgnID, PLANE_TOP)
hitXYZ#(1) = oHitData.X 'Format(oHitData.X, "0.00000;-0.00000")
hitXYZ#(2) = oHitData.Y 'Format(oHitData.Y, "0.00000;-0.00000")
hitXYZ#(3) = oHitData.Z 'Format(oHitData.Z, "0.00000;-0.00000")
Write #1, hitNum, hitXYZ(1), hitXYZ(2), hitXYZ(3)
Next hitNum
End If
End If
End If
End If
Next Cmd
Close #1
Call csvSave
Set PCDapp = Nothing
Set PCDpart = Nothing
Set Cmds = Nothing
Set Cmd = Nothing
Set FCmd = Nothing
Set fs = Nothing
Set oPointData = Nothing
Set oHitData = Nothing
End Sub
Function csvSave
Dim xlApp As Object
Dim xlWorkbooks As Object
Dim xlWorkbook As Object
Set xlApp = CreateObject("Excel.Application")
Set xlWorkbooks = xlApp.Workbooks
Set xlWorkbook = xlWorkbooks.Open(FileName)
xlWorkBook.Save
xlWorkbook.Close
Set xlWorkbook = Nothing
xlWorkbooks.Close
Set xlWorkbooks = Nothing
xlApp.Quit
Set xlApp = Nothing
End Function
Function WriteToFile
Spc = ""
Select Case Cmd.Feature
Case F_CIRCLE
If FCmd.TheoHeight = 0 Then
Write #1, CmdID, x, y, z, i, j, k, d
Else
Write #1, CmdID, x, y, z, i, j, k, d, h
End If
Case F_CONE
Write #1, CmdID, x, y, z, i, j, k, d, Spc, l, Spc, a
Case F_CYLINDER
Write #1, CmdID, x, y, z, i, j, k, d, Spc, l
Case F_ELLIPSE
Write #1, CmdID, x, y, z, i, j, k, Spc, Spc, l, w, Spc, i2, j2, k2
Case F_LINE
Write #1, CmdID, x, y, z, i, j, k, Spc, Spc, l, Spc, Spc, i2, j2, k2, x2, y2, z2, x3, y3, z3
Case F_SLOT
Write #1, CmdID, x, y, z, i, j, k, d, h, l, Spc, Spc, i2, j2, k2
Case F_SPHERE
Write #1, CmdID, x, y, z, i, j, k, d
here's my script to CSV export measured values from measured or DCC features including all hit points. Maybe it will help.
Dim PCDapp As Object
Dim PCDpart As Object
Dim Cmds As Object
Dim Cmd As Object
Dim FCmd As Object
Dim fs As Object
Dim oPointData As Object
Dim oHitData As Object
Dim x#, y#, z#, x2#, y2#, z2#, x3#, y3#, z3#
Dim i#, j#, k#, i2#, j2#, k2#
Dim d#, l#, h#, a#, w#
Dim hitXYZ#(3), hitNum%, numhits%
Dim CmdID$, Batch$, Num$, FileTime$, FileName$, FilePath$
Dim Spc$, AlgnID$
Sub Main
Set PCDapp = CreateObject("PCDLRN.Application")
Set oPointData = CreateObject("PCDLRN.PointData")
Set oHitData = CreateObject("PCDLRN.PointData")
Set PCDpart = PCDapp.ActivePartProgram
Set Cmds = PCDpart.Commands
Set fs = CreateObject("Scripting.FileSystemObject")
FilePath = PCDpart.Path & "\data"
If Not(fs.FolderExists (FilePath)) Then
retval = fs.CreateFolder(FilePath)
End If
If Cmd.IsAlignment And Cmd.ID <> "" Then
AlgnID = Cmd.ID
End If
If Cmd.Type = RECALL_ALIGN Then
AlgnID = cmd.GetText(REF_ID, 0)
End If
If Cmd.IsFeature Or Cmd.IsScan Then
If Cmd.ID <> "" Then
If Cmd.IsDCCFeature Or Cmd.IsMeasuredFeature Or Cmd.IsScan Then
CmdID = Cmd.ID
Set FCmd = Cmd.FeatureCommand
retval = FCmd.GetData(oPointData, FDATA_CENTROID, FDATA_MEAS, FDATA_PART, AlgnID, PLANE_TOP)
x = oPointData.X
y = oPointData.Y
z = oPointData.Z
retval = FCmd.GetData(oPointData, FDATA_VECTOR, FDATA_MEAS, FDATA_PART, AlgnID, PLANE_TOP)
i = oPointData.I
j = oPointData.J
k = oPointData.K
Select Case Cmd.Feature
Case F_CIRCLE
d = FCmd.MeasDiam
If FCmd.MeasHeight <> 0 Then
h = FCmd.MeasHeight
End If
Case F_CONE
a = FCmd.MeasAngle
d = FCmd.MeasDiam
l = FCmd.MeasLength
Case F_CYLINDER
d = FCmd.MeasDiam
l = FCmd.MeasLength
Case F_ELLIPSE
l = FCmd.MeasMajorAxis
w = FCmd.MeasMinorAxis
retval = FCmd.GetData(oPointData, FDATA_SLOT_VECTOR, FDATA_MEAS, FDATA_PART, AlgnID, PLANE_TOP)
i2 = oPointData.I
j2 = oPointData.J
k2 = oPointData.K
numhits = FCmd.NumHits
If numhits > 0 Then
For hitNum = 1 To numhits
Set oHitData = FCmd.GetHit(hitNum, FHITDATA_CENTROID, FDATA_MEAS, FDATA_PART, AlgnID, PLANE_TOP)
hitXYZ#(1) = oHitData.X 'Format(oHitData.X, "0.00000;-0.00000")
hitXYZ#(2) = oHitData.Y 'Format(oHitData.Y, "0.00000;-0.00000")
hitXYZ#(3) = oHitData.Z 'Format(oHitData.Z, "0.00000;-0.00000")
Write #1, hitNum, hitXYZ(1), hitXYZ(2), hitXYZ(3)
Next hitNum
End If
End If
End If
End If
Next Cmd
Close #1
Call csvSave
Set PCDapp = Nothing
Set PCDpart = Nothing
Set Cmds = Nothing
Set Cmd = Nothing
Set FCmd = Nothing
Set fs = Nothing
Set oPointData = Nothing
Set oHitData = Nothing
End Sub
Function csvSave
Dim xlApp As Object
Dim xlWorkbooks As Object
Dim xlWorkbook As Object
Set xlApp = CreateObject("Excel.Application")
Set xlWorkbooks = xlApp.Workbooks
Set xlWorkbook = xlWorkbooks.Open(FileName)
xlWorkBook.Save
xlWorkbook.Close
Set xlWorkbook = Nothing
xlWorkbooks.Close
Set xlWorkbooks = Nothing
xlApp.Quit
Set xlApp = Nothing
End Function
Function WriteToFile
Spc = ""
Select Case Cmd.Feature
Case F_CIRCLE
If FCmd.TheoHeight = 0 Then
Write #1, CmdID, x, y, z, i, j, k, d
Else
Write #1, CmdID, x, y, z, i, j, k, d, h
End If
Case F_CONE
Write #1, CmdID, x, y, z, i, j, k, d, Spc, l, Spc, a
Case F_CYLINDER
Write #1, CmdID, x, y, z, i, j, k, d, Spc, l
Case F_ELLIPSE
Write #1, CmdID, x, y, z, i, j, k, Spc, Spc, l, w, Spc, i2, j2, k2
Case F_LINE
Write #1, CmdID, x, y, z, i, j, k, Spc, Spc, l, Spc, Spc, i2, j2, k2, x2, y2, z2, x3, y3, z3
Case F_SLOT
Write #1, CmdID, x, y, z, i, j, k, d, h, l, Spc, Spc, i2, j2, k2
Case F_SPHERE
Write #1, CmdID, x, y, z, i, j, k, d