hexagon logo

How to access PC-DMIS Arrays using the Basic Script Editor?

HI everyone, 

First post here so please forgive any lack of clarity in the question.

I'm trying to pass the hit array from a scan to the Basic Script editor in order to write the measured data to a comma delimited file for further investigation on non-conforming hardware. I've read other examples on the forums but none seems to be doing what I need them to do and I can't figure this one out myself.

When I execute this code as it is now, the MsgBox command prints a 0 and the File I/O commands also prints a 0. So I don't think the data is being passed in a way that is accessible.

Any help would be greatly appreciated and let me know if any additional information is needed for clarification.

Thanks!

-Corey

PCDMIS code:

ASSIGN/X_ARRAY=ARRAY(SCN_13_1.HIT[1..SCN_13_1.NUMHITS].X)

CS2 =SCRIPT/FILENAME= D:\PCDMIS_2019\Test\Test_JOBS\OP_test\POINT_EXPORT.BAS
FUNCTION/Main,SHOW=YES,,
STARTSCRIPT/
ENDSCRIPT/

Below is a snip of the BASIC code currently:

Option Explicit

Public objFSO, objShell As Object
Public PCDApp, PCDPartProgram, PCDCommands, PCDCommand, retval As Object
Public objFile, objFolder As Object

Public xArrayOut As Object
Public xArrayOutIndex As Object
Public xArray As Object

Sub main()

Set PCDApp=CreateObject("PCDLRN.Application")
Set PCDPartProgram=PCDApp.ActivePartProgram
Set PCDCommands=PCDPartProgram.Commands
Set xArray = PCDPartProgram.GetVariableValue("X_ARRAY")
Set numberHits = PCDPartProgram.GetVariableValue("NUMHITS")

Dim tempOut As String
Dim counter As Long
Dim Start_Time As Object

counter = numberHits.LongValue
MsgBox "Counter Variable: " & counter

' Dim xArray As PCDLRN.Variable
Dim testfile As String
testFile = "D:\PCDMIS_2019\TPCE\3074T58P01_Jobs\Op200\point_data_test.txt"
Dim i As Long
For i = 1 To counter
Set xArrayOutIndex = xArray.GetArrayIndexValue(i)
'xArrayOut = xArrayOutIndex(i).LongValue
'tempOut = str(xArrayOut(i))
MsgBox xArrayOutIndex.LongValue, 0, "Title"
Open testfile For Output As #1
Print #1, xArrayOutindex.longValue
Close #1
Next i

MsgBox "End Loop"


Set Start_Time = PCDPartProgram.GetVariableValue("V2")
'Dim tempOut As String
tempOut = Start_Time.LongValue
MsgBox "Test Var Value: " & Start_time.longvalue
'Set yArray = PCDPartProgram.GetVariableValue("Y_ARRAY")
'Set zArray = PCDPartProgram.GetVariableValue("Z_ARRAY")

End Sub