Dim App As Object Dim Part As Object Dim Cmds As Object Dim Cmd As Object Sub Main (ScanID As String) ' Initialize PC-DMIS Set App = CreateObject("PCDLRN.Application") If App Is Nothing Then MsgBox "PC-DMIS initialization error!",48, "Error!" Exit Sub Else Set Part = App.ActivePartProgram If Part Is Nothing Then MsgBox "Part Program not opened!", 48, "Error!" Exit Sub Else Set Cmds = Part.Commands If Cmds Is Nothing Then MsgBox "Pointer to commands not valid!", 48, "Error!" Exit Sub End If End If End If ' Locate Scan For Each Cmd In Cmds If Cmd.isfeature Then If Cmd.ID = ScanID Then Set ScanCmd = Cmd Set ScanHits = ScanCmd.FeatureCommand Exit For End If End If Next Cmd ' Report And Exit If Scan Not Found If ScanCmd Is Nothing Then MsgBox "Scan Not Found!", 48, "Error!" Exit Sub End If ' Create point data objects Set Hit = CreateObject("PCDLRN.PointData") Set Vec = CreateObject("PCDLRN.PointData") ' Get the number of hits In the scan NH = ScanHits.NumHits CNT= CInt(NH) ' Set startnum To 1 And endnum To the # of hits (nh) StartNum = 1 EndNum = NH Open "C:\TMP\" & ScanID & ".txt" For Output As #1 Write #1, ScanID For i = StartNum To EndNum Set hit = ScanHits.GetHit(i, FHITDATA_BALLCENTER, FDATA_MEAS, FDATA_PART, AlignID, PLANE_TOP) HitX = CDbl(hit.x) HitY = CDbl(hit.y) HitZ = CDbl(hit.z) Set vec = ScanHits.GetHit(i, FHITDATA_VECTOR, FDATA_MEAS, FDATA_PART, AlignID, PLANE_TOP) HitI = CDbl(vec.x) HitJ = CDbl(vec.y) HitK = CDbl(vec.z) Write #1, HitX, HitY, HitZ, HitI, HitJ, HitK Next Close #1 End Sub