Sub Main() ' ' ' ' Create And initialize the PCDMIS Application Object Const PI = 3.1415926 Dim DmisApp As Object Set DmisApp = CreateObject("PCDLRN.Application") ' Create And initialize the PCDMIS Part Object Dim DmisPart As Object Set DmisPart = DmisApp.ActivePartProgram ' Create And initialize the PCDMIS Commands Object Dim DmisCommands As Object Set DmisCommands = DmisPart.Commands Dim DmisCommand As Object Dim Xn_MEAS, Yn_MEAS, Zn_MEAS As Double Dim X_MEAS, Y_MEAS, Z_MEAS As Double Dim X_THEO, Y_THEO, Z_THEO As Double Dim FeatureName As String Dim FeatureCmd As Object For Each DmisCommand In DmisCommands If DmisCommand.IsFeature And DmisCommand.Feature = F_Circle And DmisCommand.Marked Then 'Get the ID FeatureName = DmisCommand.Id If FeatureName = "H3520M001" Then Set FeatureCmd = DmisCommand.FeatureCommand ' Get the Nominal And Measured XYZ values FeatureCmd.GetPoint FPOINT_CENTROID, FDATA_THEO, X_THEO, Y_THEO, Z_THEO FeatureCmd.GetPoint FPOINT_CENTROID, FDATA_MEAS, X_MEAS, Y_MEAS, Z_MEAS FeatureCmd.GetVector FVECTOR_VECTOR, FDATA_MEAS, Xn_MEAS, Yn_MEAS, Zn_MEAS End If End If Next DmisCommand 'Calculate the angle between the hole plane normal And Y axis Dim cos_theta, sin_theta As Double cos_theta = Yn_MEAS 'calculated from the dot product of the normal vector And Y axis sin_theta = sqr(1 - cos_theta ^ 2) 'Calculate the coordinates of the theoretical And measured hole center under the new coordinate system. Rotate the coord sys around X axis. Dim X_THEO_NEW, Y_THEO_NEW, Z_THEO_NEW As Double Dim X_MEAS_NEW, Y_MEAS_NEW, Z_MEAS_NEW As Double Z_THEO_NEW = sin_theta * Y_THEO + cos_theta * Z_THEO Z_MEAS_NEW = sin_theta * Y_MEAS + cos_theta * Z_MEAS Dim DeltaZ As Double DeltaZ = Z_MEAS_NEW - Z_THEO_NEW Dim FName As String FName = "C:\Users\t8668kx\Work\test.txt" Open FName For Output As 1 Print #1, DeltaZ Close DmisPart.RefreshPart End Sub