hexagon logo

Code to capture dimension data from PC dmis

I've managed to script up the deviation from nominal and output this in a desired format but I'm having trouble getting the dimensions out out such as Dimension_3D_Distance below is a sample of the code i was trying to use any pointers would be much appreciated thanks in advance.

Sub Main(SNO As String, PARTDIR As String, PARTPRG As String, PART As String)
Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand, PCDReport, PCDDataTypes, PCDDataType, PCDFeatCmd
Dim DimT, tX, tY, tZ, mX, mY, mZ, mi, mj, mk, PCDID As String
Dim StrTemp, StrFname, strNetFname, strPFname
Dim m, i As Integer
Dim MyPntMeas, MyPntTheo, MyPntVect
Dim II, JJ, KK, T As Double


Dim DimName() As String
Dim Dims()

Set PCDApp = CreateObject("PCDLRN.Application")
Set PCDPartPrograms = PCDApp.PartPrograms
Set PCDPartProgram = PCDApp.ActivePartProgram
Set PCDCommands = PCDPartProgram.Commands


Dim iCnt As Integer
i = "0"

strTemp = Format(Now(), "yymmddhhnn")& ".PTS"
strNetFname = PARTDIR & SNO & "-Deviation-" & strTemp
strPFname = strFname

Open strNetFname For Output As #1


Print #1,"~DOC: " & SNO & "_"&Format(Now(), "yymmddhhnn")

Print #1,"Part = " & PART
Print #1,"OPERATOR = "
Print #1,"CMM = "
Print #1,"CMMPROG = " & PARTPRG
Print #1,"PART_STATUS = ----------"
Print #1,"PARTCOUNT = ----------"
Print #1,"OPERATION = F"
Print #1,"DATE = " & Format(Now(), "yymmddhhmm")
Print #1,"TIMEINT = ----------"
Print #1,"SerialNumber = " & SNO
Print #1, ""

For iCnt = 1 To PCDCommands.Count
Set PCDCommand = PCDCommands.Item(iCnt)

If PCDCommand.isConstructedFeature Or PCDCommand.Type = 210 Then

Set PCDFeatCmd = PCDCommand.FeatureCommand

Print #1,""
If mid(PCDFeatCmd.ID,6)="_" Then
Print #1,"Section " & Left(PCDFeatCmd.ID,5)
Print #1,""
Else
Print #1,"Section " & Left(PCDFeatCmd.ID,7)
Print #1,""
End If

For m =1 To PCDFeatCmd.NumHits



Set MyPntMeas = PCDFeatCmd.GetHit(m,FHITDATA_CENTROID,FDATA_MEAS,FDATA_PART,"",PLANE_TOP)
Set MyPntTheo = PCDFeatCmd.GetHit(m,FHITDATA_CENTROID,FDATA_THEO,FDATA_PART,"",PLANE_TOP)
Set MyPntVect = PCDFeatCmd.GetHit(m,FHITDATA_VECTOR,FDATA_THEO,FDATA_PART,"",PLANE_TOP)

XM = MyPntMeas.X
YM = MyPntMeas.Y
ZM = MyPntMeas.Z
XN = MyPntTheo.X
YN = MyPntTheo.Y
ZN = MyPntTheo.Z
II = MyPntVect.X
JJ = MyPntVect.Y
KK = MyPntVect.Z

T = ((XM-XN)*II) + ((YM-YN)*JJ) + ((ZM-ZN)*KK)

i = iCnt+1

ReDim DimName(i)
ReDim Dims(i)

DimName(i) = PCDFeatCmd.ID & "_" & format(m,"00")
Dims (i) = format(T,"###0.000")
Print #1,DimName(i)&": "& Dims(i)


Next m
End If

Next iCnt
Erase DimName
Erase Dims


For iCnt = 1 To PCDCommands.Count

Set PCDCommand = PCDCommands.Item(iCnt)

If PCDCommand.Type = 1105 Or PCDCommand.Type = 1106 Then

Set objDimCmd= PCDCommand.DimensionCommand

Print #1,""
Print #1,"Section " & PCDCommand

Set Measure = ObjCmd.GetText(iCnt,Dimension_3D_Distance,0)
'Set Measure = ObjCmd.GetText(iCnt,DIM_MEASURED,0)

Print #1, Measure

End If

Next iCnt

Close #1
Set PCDCommands = Nothing
Set PCDPartProgram = Nothing
Set PCDPartPrograms = Nothing
Set PCDApp = Nothing
Set PCDReport = Nothing
End Sub