I've tried the following basic code (generated by the OldBasic converter).
Sub main
Dim i, j, k As Integer ' working vars
Dim tpoint As Object
Set tpoint = CreateObject("PCDLRN.PointData")
Dim AutoApp As Object
Set AutoApp = CreateObject("PCDLRN.Application")
Dim AutoPart As Object
Set AutoPart = AutoApp.ActivePartProgram
Dim AutoOldBasicOb As Object
Set AutoOldBasicOb = AutoPart.OldBasic
i = AutoOldBasicOb.StartGetFeatPoint("CIR1",PCD_MEAS, PCD__BALLCENTER)
For j = 1 To i
msgbox i & " - " & j
AutoOldBasicOb.GetFeatPoint( tpoint, j)
msgbox "Got past the GetFeatPoint call"
Next j
End Sub
The circle ("C1") has four points, which the call to AutoOldBasicObStartGetFeatPoint returns correctly.
However, the call to AutoOldBasicOb.GetFeatPoint( tpoint, j) has two problems:
1. It won't run if I attempt to assign the result of this funtion to an integer (e.g. k = AutoOldBasicOb.GetFeatPoint( tpoint, j) ) I get a type mismatch error, which indicates that the function is not returning an integer as indicated in the manual.
2. Once executed, the program blows up without an error, and ceases to run. That is, I'll never get to the second MSGBOX call.
Is there another way to get at the basic hit data for this circle? I can find non-OldBasic objects that let me get at the dimensions of it, but not the individual hits themselves. This is more than a little exasperating...
FWIW: I struggled through the (lack of) documentation and came up with the following PC-DMIS program/VB program that takes numerous circles up and down a cylinder, accesses the individual points that comprise the hits, turns them into diameters, and then writes them into a comma-delimited file that can be read directly into XL.
Obvious improvements might be to insert directly into spreadsheet, or have a spreadsheet open the program and run it using a more true automation.
Note to Wilcox: Better documentation, including samples of how each feature is used, would be very welcome. Also, it seems that some things don't work as I would have expected. For instance, I couldn't dim an array of PointData, nor set the individual components of an array. Hence I had to use arrays of doubles to hold the X and Y components of a PointData object, rather than being able to iterate through the array and use the points themselves.
This is a very powerful tool that would be much more useful with some solid examples of coding that could be used as building blocks.
**** BEGIN PC-DMIS program
PART NAME : DB07RN602AID
REV NUMBER :
SER NUMBER :
STATS COUNT : 1
STARTUP =ALIGNMENT/START,RECALL:,LIST=YES
ALIGNMENT/END
MODE/MANUAL
FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,MEAS,MAXMIN,TOL,DEV,OUTTOL,
LOADPROBE/14MMSPHERE
TIP/T1A0B0, SHANKIJK=0, 0, 1, ANGLE=0
*** MANUAL ALILGNMENT CODE DELETED FOR SPACE REASONS
MODE/DCC
C1 =COMMENT/INPUT,NO,'Enter the part id'
ASSIGN/PARTID = C1.INPUT
ASSIGN/THISFILENAME = TEST
CS1 =SCRIPT/FILENAME= C:\CMM PROGRAMS\FTE\DB07RN602A\DB07RN602AID.BAS
FUNCTION/CreateFIle,SHOW=YES,,
STARTSCRIPT/
ENDSCRIPT/
PLN2 =FEAT/PLANE,CARTESIAN,TRIANGLE
THEO/<-11.502,-81.816,-56.43>,<-0.000006,0.0000043,1>
ACTL/<-11.51,-81.81,-56.433>,<0.0000158,0.0000003,1>
MEAS/PLANE,4
HIT/BASIC,NORMAL,<-111.621,-72.624,-56.431>,<-0.000006,0.0000043,1>,<-111.62,-72.655,-56.432>,USE THEO = YES
HIT/BASIC,NORMAL,<68.916,-73.045,-56.43>,<-0.000006,0.0000043,1>,<68.909,-73.075,-56.435>,USE THEO = YES
HIT/BASIC,NORMAL,<68.874,-90.692,-56.43>,<-0.000006,0.0000043,1>,<68.868,-90.667,-56.435>,USE THEO = YES
HIT/BASIC,NORMAL,<-72.176,-90.902,-56.43>,<-0.000006,0.0000043,1>,<-72.197,-90.843,-56.432>,USE THEO = YES
ENDMEAS/
LIN2 =FEAT/LINE,CARTESIAN,UNBOUNDED
THEO/<-99.494,-108.564,-44.495>,<1,-0.0002276,0>
ACTL/<-99.504,-106.343,-44.502>,<1,-0.000116,0>
MEAS/LINE,2,WORKPLANE
HIT/BASIC,NORMAL,<-99.509,-108.564,-44.498>,<0.0002276,1,0>,<-99.504,-106.343,-44.505>,USE THEO = YES
HIT/BASIC,NORMAL,<8.198,-108.588,-44.492>,<0.0002276,1,0>,<8.191,-106.355,-44.499>,USE THEO = YES
ENDMEAS/
MOVE/POINT,NORMAL,<15.455,-94.29,26.403>
MOVE/POINT,NORMAL,<-1.486,-7.835,26.402>
CYL2 =FEAT/CYLINDER,CARTESIAN,IN,LEAST_SQR
THEO/<0.017,-0.024,-20.975>,<-0.0012422,-0.0022099,0.9999968>,46.953,28.303
ACTL/<0.002,-0.023,-20.983>,<-0.0007906,-0.0007831,0.9999994>,47.002,28.299
MEAS/CYLINDER,8
HIT/BASIC,NORMAL,<1.563,23.465,-35.088>,<-0.0929248,-0.9956704,-0.0023157>,<1.225,23.501,-35.113>,USE THEO = YES
HIT/BASIC,NORMAL,<23.502,-1.04,-35.086>,<-0.9979557,0.0639001,-0.0010984>,<23.534,-0.766,-35.111>,USE THEO = YES
HIT/BASIC,NORMAL,<-1.103,-23.405,-35.086>,<-0.0091691,0.9999555,0.0021984>,<-1.714,-23.496,-35.112>,USE THEO = YES
HIT/BASIC,NORMAL,<-23.239,2.771,-35.089>,<0.9858169,-0.1678224,0.0008537>,<-23.41,2.259,-35.11>,USE THEO = YES
HIT/BASIC,NORMAL,<-23.166,2.772,-6.863>,<0.984989,-0.1726149,0.0008421>,<-23.354,2.231,-6.852>,USE THEO = YES
HIT/BASIC,NORMAL,<-0.382,23.359,-6.861>,<0.0574012,-0.9983489,-0.0021349>,<0.086,23.439,-6.842>,USE THEO = YES
HIT/BASIC,NORMAL,<23.411,0.045,-6.859>,<-0.9999835,-0.0056001,-0.0012545>,<23.446,0.017,-6.841>,USE THEO = YES
HIT/BASIC,NORMAL,<0.381,-23.504,-6.859>,<-0.0226806,0.9997404,0.0021811>,<0.263,-23.502,-6.851>,USE THEO = YES
MOVE/POINT,NORMAL,<0.354,-1.401,-6.86>
MOVE/POINT,NORMAL,<0.353,-1.401,12.903>
ENDMEAS/
PNT2 =FEAT/POINT,CARTESIAN
THEO/<0.382,-25.346,0.043>,<0,0,1>
ACTL/<0.334,-25.327,-0.009>,<0,0,1>
MEAS/POINT,1
HIT/BASIC,NORMAL,<0.382,-25.346,0.043>,<0,0,1>,<0.334,-25.327,-0.009>,USE THEO = YES
ENDMEAS/
A2 =ALIGNMENT/START,RECALL:A1,LIST=YES
ALIGNMENT/LEVEL,ZPLUS,PLN2
ALIGNMENT/ROTATE,XPLUS,TO,LIN2,ABOUT,ZPLUS
ALIGNMENT/TRANS,ZAXIS,PNT2
ALIGNMENT/TRANS,XAXIS,CYL2
ALIGNMENT/TRANS,YAXIS,CYL2
ALIGNMENT/END
V1 =LOOP/START, ID = YES, NUMBER = 18, START = 1, SKIP = ,
OFFSET: XAXIS = 0, YAXIS = 0, ZAXIS = -2, ANGLE = 0
CIR1 =FEAT/CIRCLE,CARTESIAN,IN,LEAST_SQR
THEO/<-0.073,0.046,-2>,<0.0000156,0.0000042,1>,47.048
ACTL/<-18.646,21.262,-2.15>,<0.0000151,0.0000067,1>,45.167
MEAS/CIRCLE,72,WORKPLANE
*** 72 HITs deleted here for space purposes
** BEGIN BASIC PROGRAM
Function dist_2d(x1, x2 As Double, y1, y2 As Double)
dist_2d = sqr((x1 - x2)^2 +(y1 - y2)^2)
End Function
Sub CreateFile
Dim st As String
Dim AutoApp As Object
Set AutoApp = CreateObject("PCDLRN.Application")
Dim AutoPart As Object
Set AutoPart = AutoApp.ActivePartProgram
' Get the ID To construct a unique file Name
Dim var As Object
Set var = AutoPart.GetVariableValue("PARTID")
thisfilename = "C:\CMM Programs\FTE\DB07RN602A\DB07RN602AID" & var.StringValue
thisfilename = thisfilename & "-" & format(now,"dd-mm-yy-hh-nn") & ".txt"
'assign it To internal variable For Next time
Dim filename As Object
Set filename = AutoPart.GetVariableValue("THISFILENAME")
filename.stringvalue = thisfilename
Autopart.SetVariableValue "THISFILENAME" ,filename
On Error Resume Next
kill thisfilename
On Error GoTo 0
Open thisfilename For Output As #1
End Sub
Sub Circ1
Dim i, j, k As Integer ' working vars
Dim xarray(72) As Double ' WILL HOLD THE POINTS For Each MEASUREMENT
Dim yarray(72) As Double ' WILL HOLD THE POINTS For Each MEASUREMENT
Dim tpoint As Object
Set tpoint = CreateObject("PCDLRN.PointData")
Dim st As String
Dim AutoApp As Object
Set AutoApp = CreateObject("PCDLRN.Application")
Dim AutoPart As Object
Set AutoPart = AutoApp.ActivePartProgram
Dim cmds As Commands
Set cmds = AutoPart.Commands
Dim cmd As Command
Set cmd = cmds.Item("CIR1")
'Dim var As Object
Set var = AutoPart.GetVariableValue("THISFILENAME")
thisfilename = var.StringValue
Dim fcmd As Object
Set fcmd =cmd.FeatureCommand ' Get the feature command property
'msgbox fcmd.id & " - " & fcmd.numhits
For i = 1 To fcmd.numhits
Set tpoint = fcmd.GetHit(i,FHITDATA_CENTROID,FDATA_MEAS,FDATA_PART,"",PLANE_TOP)
xarray(i) = tpoint.x
yarray(i) = tpoint.y
Next i
Open thisfilename For Append As #1
st = "Depth: " & format(tpoint.z,"###.0000") & ", " ' always the same
k = fcmd.numhits / 2 '' divide number of hits by 2 For diameters
For i = 1 To k
st = st & format(dist_2d(xarray(i), xarray(i+k), yarray(i), yarray(i+k)),"##.0000") & ", "
Next
st = left(st,len(st) - 2) ' strip off the last comma,space
Print #1, st
End Sub