hexagon logo

Help with OLE Automation

Now that I have information in a way that imports and exports the information correctly, I have been tasked with creating an OLE to automatically import the data into the SPC software. I have one that sort of works (as in opens the program, logs in, opens the right collection plan, etc) and I can get put in static information, but I am unsure how to call the information out of PC DMIS to have it be placed in the spots we need in the SPC software being used.

Has anyone else done this? Can anyone explain to me how find the variable and the measurement output in PC DMIS? I am using version 4.2 if that helps any.

Thanks so much.
  • So here is an example of what the program is saying:

    Set DmisCommand = DmisCommands.Add(DIMENSION_START_LOCATION, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Id = CIRC2 DIA
    retval = DmisCommand.PutText ("CIRC2 DIA", ID, 0)
    ' Set Reference Id = CIR2- OUTER CIRCLE ABOVE STEP
    retval = DmisCommand.PutText ("CIR2- OUTER CIRCLE ABOVE STEP", REF_ID, 0)
    ' Set Graphic Analysis = OFF
    retval = DmisCommand.SetToggleString (1, GRAPH_ANALYSIS, 0)
    ' Set Textual Analysis = OFF
    retval = DmisCommand.SetToggleString (1, TEXT_ANALYSIS, 0)
    ' Set Arrow Multiplier = 10.000000
    retval = DmisCommand.PutText ("10.000000", ARROW_MULTIPLIER, 0)
    ' Set Output Type = BOTH
    retval = DmisCommand.SetToggleString (3, OUTPUT_TYPE, 0)
    ' Set Unit Type = IN
    retval = DmisCommand.SetToggleString (1, UNIT_TYPE, 0)
    ' Set Standard Deviation = 0.000300
    retval = DmisCommand.PutText ("0.000300", STANDARD_DEVIATION, 0)

    Set DmisCommand = DmisCommands.Add(DIMENSION_D_LOCATION, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Nominal = 3.6460
    retval = DmisCommand.PutText (" 3.6460", NOMINAL, 0)
    ' Set Measured = 3.6433
    retval = DmisCommand.PutText (" 3.6433", DIM_MEASURED, 0)
    ' Set Plus Tolerance = 0.0020
    retval = DmisCommand.PutText (" 0.0020", F_PLUS_TOL, 0)
    ' Set Minus Tolerance = 0.0020
    retval = DmisCommand.PutText (" 0.0020", F_MINUS_TOL, 0)
    ' Set Max = 3.6444
    retval = DmisCommand.PutText (" 3.6444", DIM_MAX, 0)
    ' Set Min = 3.6427
    retval = DmisCommand.PutText (" 3.6427", DIM_MIN, 0)
    ' Set Deviation = -0.0027
    retval = DmisCommand.PutText (" -0.0027", DIM_DEVIATION, 0)
    ' Set Out Tol = 0.0007
    retval = DmisCommand.PutText (" 0.0007", DIM_OUTTOL, 0)

    Set DmisCommand = DmisCommands.Add(DIMENSION_END_LOCATION, TRUE)
    DmisCommand.Marked = TRUE

    I have tried the ID and the REF_ID and I still get a zero reading, although this tells me that it is getting a measurement. But there is no set Axis in this section, but in the roundess there is:

    Set DmisCommand = DmisCommands.Add(DIMENSION_CIRCULARITY, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Id = CIR2 ROUNDNESS
    retval = DmisCommand.PutText ("CIR2 ROUNDNESS", ID, 0)
    ' Set Reference Id = CIR2- OUTER CIRCLE ABOVE STEP
    retval = DmisCommand.PutText ("CIR2- OUTER CIRCLE ABOVE STEP", REF_ID, 0)
    ' Set Unit Type = IN
    retval = DmisCommand.SetToggleString (1, UNIT_TYPE, 0)
    ' Set Graphic Analysis = OFF
    retval = DmisCommand.SetToggleString (1, GRAPH_ANALYSIS, 0)
    ' Set Textual Analysis = OFF
    retval = DmisCommand.SetToggleString (1, TEXT_ANALYSIS, 0)
    ' Set Arrow Multiplier = 10.000000
    retval = DmisCommand.PutText ("10.000000", ARROW_MULTIPLIER, 0)
    ' Set Output Type = BOTH
    retval = DmisCommand.SetToggleString (3, OUTPUT_TYPE, 0)
    ' Set Axis = M
    retval = DmisCommand.PutText ("M", AXIS, 0)
    ' Set Nominal = 0.0000
    retval = DmisCommand.PutText (" 0.0000", NOMINAL, 0)
    ' Set Measured = 0.0009
    retval = DmisCommand.PutText (" 0.0009", DIM_MEASURED, 0)
    ' Set Plus Tolerance = 0.0050
    retval = DmisCommand.PutText (" 0.0050", F_PLUS_TOL, 0)
    ' Set Minus Tolerance = 0.0000
    retval = DmisCommand.PutText (" 0.0000", F_MINUS_TOL, 0)
    ' Set Max = 0.0005
    retval = DmisCommand.PutText (" 0.0005", DIM_MAX, 0)
    ' Set Min = -0.0003
    retval = DmisCommand.PutText (" -0.0003", DIM_MIN, 0)
    ' Set Deviation = 0.0009
    retval = DmisCommand.PutText (" 0.0009", DIM_DEVIATION, 0)
    ' Set Out Tol = 0.0000
    retval = DmisCommand.PutText (" 0.0000", DIM_OUTTOL, 0)
    ' Set Standard Deviation = 0.000162
    retval = DmisCommand.PutText ("0.000162", STANDARD_DEVIATION, 0)

    Could this be the problem? If so, how do I fix it? Any other suggestions on how to get this to work properly? So far, I have tried every combination that I can think of....ID and Axis letter...ID, REF_ID, I am at a loss.

    Thanks.
  • Hmm... You should have an axisletter "D" for the diameter... Bug?

    What code do you have at the moment?
  • I am not sure what you mean by what code I have at the moment. My code that is putting the data some place else or the code from the CMM that I exported?
  • OK, so I found in the code the Feature Command MeasDiam which should give me the same as the dimension output for the diameter. But I think I originally called it out wrong since I kept getting a block or undeclared variable error. So I changed it to this, and it is untested.

    Begin VB.Form Form1
    caption = "Visual Basic OLE Client for WinSPC"
    ClientHeight = 4485
    ClientLeft = 60
    ClientTop = 630
    ClientWidth = 6150
    LinkTopic = "Form1"
    ScaleHeight = 4485
    ScaleWidth = 6150
    Begin VB.TextBox Text1
    Height = 4455
    Left = 0
    MultiLine = -1 'True
    ScrollBars = 2 'Vertical
    TabIndex = 0
    Top = 0
    Width = 6135
    End
    Begin VB.Menu RunMenu
    Caption = "&Run"
    End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredID = True
    Attribute VB_Expose = False





    'Declare variables
    Sub main
    Dim PartObj As Object
    Dim CPObj As Object
    Dim DCObj As Object
    Dim DBObj As Object
    Dim UserName As String
    Dim Password As String
    Dim sPart As String
    Dim sVar1 As String
    Dim sVar2 As String
    Dim sCollPlan As String
    Dim PartID As Long
    Dim Var1ID As Long
    Dim Var2ID As Long
    Dim CollPlanID As Long
    Dim Step1ID As Long
    Dim Step2ID As Long
    Dim CollectionPlanID As Object
    Dim dc As Object
    Dim ObjApp As Object

    'PCDMIS commands
    Dim ObjPP As Object
    Dim ObjCmds As Object
    Dim ObjCmd As Object
    Dim ObjPart As Object
    Dim lngNumCmds As Long
    Set ObjApp = CreateObject("PCDLRN.Application")
    Set ObjPart = ObjApp.ActivePartProgram
    Set ObjCmds = ObjPart.Commands
    set lngNumCmds = ObjCmds.Count


    Dim StrDimID As String
    Dim StrDimFeature As String
    Dim StrDimType As String
    Dim StrDimNominal As String
    Dim StrDimUTol As String
    Dim StrDimLTol As String
    Dim StrDimMeasure As String
    Dim StrDimActual As String
    Dim StrDimDiameter As String
    Dim MyReading1 As Double
    Dim MyReading2 As Double
    Dim MyReading3 As Double
    Dim MyReading4 As Double
    Dim MyReading5 As Double
    Dim MyReading6 As Double
    Dim MyReading7 As Double
    Dim MyReading8 As Double
    Dim MyReading9 As Double
    Dim MyReading10 As Double
    Dim MyReading11 As Double
    Dim MyReading12 As Double
    Dim MyReading13 As Double
    Dim MyReading14 As Double
    Dim MyReading15 As Double
    Dim MyReading16 As Double


    For Each ObjCmd In ObjCmds
    If ObjCmd.IsDimension Then
    StrDimID = ObjCmd.DimensionCommand.ID
    StrDimFeature = ObjCmd.DimensionCommand.Feat1
    StrDimType = ObjCmd.DimensionCommand.AxisLetter
    StrDimNominal = ObjCmd.DimensionCommand.Nominal
    StrDimUTol = ObjCmd.DimensionCommand.Plus
    StrDimLTol = ObjCmd.DimensionCommand.Minus
    StrDimMeasure = ObjCmd.DimensionCommand.Measured
    Else If ObjCmd.IsFeature Then
    StrDimDiameter=ObjCmd.FeatureCommand.MeasDiam
    End If




    If StrDimID = "CIRC2 DIA" Then MyReading1 = StrDimDiameter
    If StrDimID = "CIR2 ROUNDNESS" Then MyReading2 = StrDimMeasure
    If StrDimID = "CIRC3 DIA" Then MyReading3 = StrDimDiameter
    If StrDimID = "CIRC4 DIA" Then MyReading4 = StrDimDiameter
    If StrDimID = "CIRC7 DIA" Then MyReading5 = StrDimDiameter
    If StrDimID = "CIRC8 DIA" Then MyReading6 = StrDimDiameter
    If StrDimID = "CIRC6 DIA" Then MyReading7 = StrDimDiameter
    If StrDimID = "CIRC6 ROUNDNESS" Then MyReading8 = StrDimMeasure
    If StrDimID = "POINT1 Z" Then MyReading9 = StrDimMeasure
    If StrDimID = "POINT2 Z" Then MyReading10 = StrDimMeasure
    If StrDimID = "POINT3 Z" Then MyReading11 = StrDimMeasure
    If StrDimID = "POINT4 Z" Then MyReading12 = StrDimMeasure
    If StrDimID = "DIST1" Then MyReading13 = StrDimMeasure
    If StrDimID = "CONC1" Then MyReading14 = StrDimMeasure
    If StrDimID = "CONC2" Then MyReading15 = StrDimMeasure
    If StrDimID = "PLANE5 Z" Then MyReading16 = StrDimMeasure
    Next




    'Open WinSPC and Collection Plan
    Set dc = CreateObject("WinSPC.DataCollectionAuto")
    dc.Visible = True
    dc.RunHeadless = False
    While dc.ReadyForLogin = "F"
    Wend
    dc.UserName = "1675 CMM"
    dc.Password = "1675"

    dc.CollectionPlanID = 8544
    dc.TagIndex = 0
    dc.TagValue = KKH
    dc.CurrentStep = 0
    dc.Value = MyReading1
    dc.CurrentStep = 1
    dc.Value = MyReading2
    dc.CurrentStep = 2
    dc.Value = MyReading3
    dc.CurrentStep = 3
    dc.Value = MyReading4
    dc.CurrentStep = 4
    dc.Value = MyReading5
    dc.CurrentStep = 5
    dc.Value = MyReading6
    dc.CurrentStep = 6
    dc.Value = MyReading7
    dc.CurrentStep = 7
    dc.Value = MyReading8
    dc.CurrentStep = 8
    dc.Value = MyReading9
    dc.CurrentStep = 9
    dc.Value = MyReading10
    dc.CurrentStep = 10
    dc.Value = MyReading11
    dc.CurrentStep = 11
    dc.Value = MyReading12
    dc.CurrentStep = 12
    dc.Value = MyReading13
    dc.CurrentStep = 13
    dc.Value = MyReading14
    dc.CurrentStep = 14
    dc.Value = MyReading15
    dc.CurrentStep = 15
    dc.Value = MyReading16

    dc.CollectionPlanID = 0
    dc.UserName = " "
    set dc = Nothing
    End Sub


    So, if this works tomorrow morning, I am making progress. Slight smile

    Also, do you have an idea on what I could do with the Point1, Point2, etc variables. I have not seen an alternative to getting the results of those or the Plane 5 variable. Will post that code below.
  • Set DmisCommand = DmisCommands.Add(MOVE_POINT, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Learn Mode = NORMAL
    retval = DmisCommand.SetToggleString (1, NORM_RELEARN, 0)
    ' Set Theoretical X = 2.8233
    retval = DmisCommand.PutText ("2.8233", THEO_X, 0)
    ' Set Theoretical Y = 0.3198
    retval = DmisCommand.PutText ("0.3198", THEO_Y, 0)
    ' Set Theoretical Z = 1.1771
    retval = DmisCommand.PutText ("1.1771", THEO_Z, 0)

    Set DmisCommand = DmisCommands.Add(MEASURED_CIRCLE, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Theoretical X = 0.0034
    retval = DmisCommand.PutText ("0.0034", THEO_X, 0)
    ' Set Theoretical Y = -0.0349
    retval = DmisCommand.PutText ("-0.0349", THEO_Y, 0)
    ' Set Theoretical Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", THEO_Z, 0)
    ' Set Theoretical I = 0
    retval = DmisCommand.PutText ("0", THEO_I, 0)
    ' Set Theoretical J = 0
    retval = DmisCommand.PutText ("0", THEO_J, 0)
    ' Set Theoretical K = 1
    retval = DmisCommand.PutText ("1", THEO_K, 0)
    ' Set Theoretical Diameter = 3.643
    retval = DmisCommand.PutText ("3.643", THEO_DIAM, 0)
    ' Set Measured X = 0.0003
    retval = DmisCommand.PutText ("0.0003", MEAS_X, 0)
    ' Set Measured Y = 0
    retval = DmisCommand.PutText ("0", MEAS_Y, 0)
    ' Set Measured Z = 0.1675
    retval = DmisCommand.PutText ("0.1675", MEAS_Z, 0)
    ' Set Measured I = 0
    retval = DmisCommand.PutText ("0", MEAS_I, 0)
    ' Set Measured J = 0
    retval = DmisCommand.PutText ("0", MEAS_J, 0)
    ' Set Measured K = 1
    retval = DmisCommand.PutText ("1", MEAS_K, 0)
    ' Set Measured Diameter = 3.643
    retval = DmisCommand.PutText ("3.643", MEAS_DIAM, 0)
    ' Set Id = CIR3- RADIUS OF STEP OUTER EDGE
    retval = DmisCommand.PutText ("CIR3- RADIUS OF STEP OUTER EDGE", ID, 0)
    ' Set Coordinate Type = CARTESIAN
    retval = DmisCommand.SetToggleString (1, COORD_TYPE, 0)
    ' Set Inner/Outer = OUT
    retval = DmisCommand.SetToggleString (1, INOUT_TYPE, 0)
    ' Set Best Fit Math Type = LEAST_SQR
    retval = DmisCommand.SetToggleString (1, BF_MATH_TYPE, 0)
    ' Set 2D/3D = WORKPLANE
    retval = DmisCommand.SetToggleString (3, MEASURED_2D3D_TYPE, 0)
    ' Set Number of Hits = 8
    retval = DmisCommand.PutText ("8", N_HITS, 0)

    Set DmisCommand = DmisCommands.Add(BASIC_HIT, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Theoretical X = 1.8249
    retval = DmisCommand.PutText ("1.8249", THEO_X, 0)
    ' Set Theoretical Y = -0.0349
    retval = DmisCommand.PutText ("-0.0349", THEO_Y, 0)
    ' Set Theoretical Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", THEO_Z, 0)
    ' Set Theoretical I = 1
    retval = DmisCommand.PutText ("1", THEO_I, 0)
    ' Set Theoretical J = 0
    retval = DmisCommand.PutText ("0", THEO_J, 0)
    ' Set Theoretical K = 0
    retval = DmisCommand.PutText ("0", THEO_K, 0)
    ' Set Measured X = 1.8214
    retval = DmisCommand.PutText ("1.8214", MEAS_X, 0)
    ' Set Measured Y = -0.0337
    retval = DmisCommand.PutText ("-0.0337", MEAS_Y, 0)
    ' Set Measured Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", MEAS_Z, 0)
    ' Set Measured I = 0.9998279
    retval = DmisCommand.PutText ("0.9998279", MEAS_I, 0)
    ' Set Measured J = -0.0185529
    retval = DmisCommand.PutText ("-0.0185529", MEAS_J, 0)
    ' Set Measured K = 0
    retval = DmisCommand.PutText ("0", MEAS_K, 0)
    ' Set Learn Mode = NORMAL
    retval = DmisCommand.SetToggleString (1, NORM_RELEARN, 0)
    ' Set Use Theoretical Vector = YES
    retval = DmisCommand.SetToggleString (2, USE_THEO, 0)

    Set DmisCommand = DmisCommands.Add(MOVE_CIRCULAR, TRUE)
    DmisCommand.Marked = TRUE

    Set DmisCommand = DmisCommands.Add(BASIC_HIT, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Theoretical X = 1.2914
    retval = DmisCommand.PutText ("1.2914", THEO_X, 0)
    ' Set Theoretical Y = 1.2531
    retval = DmisCommand.PutText ("1.2531", THEO_Y, 0)
    ' Set Theoretical Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", THEO_Z, 0)
    ' Set Theoretical I = 0.7071068
    retval = DmisCommand.PutText ("0.7071068", THEO_I, 0)
    ' Set Theoretical J = 0.7071068
    retval = DmisCommand.PutText ("0.7071068", THEO_J, 0)
    ' Set Theoretical K = 0
    retval = DmisCommand.PutText ("0", THEO_K, 0)
    ' Set Measured X = 1.3068
    retval = DmisCommand.PutText ("1.3068", MEAS_X, 0)
    ' Set Measured Y = 1.2696
    retval = DmisCommand.PutText ("1.2696", MEAS_Y, 0)
    ' Set Measured Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", MEAS_Z, 0)
    ' Set Measured I = 0.717163
    retval = DmisCommand.PutText ("0.717163", MEAS_I, 0)
    ' Set Measured J = 0.6969054
    retval = DmisCommand.PutText ("0.6969054", MEAS_J, 0)
    ' Set Measured K = 0
    retval = DmisCommand.PutText ("0", MEAS_K, 0)
    ' Set Learn Mode = NORMAL
    retval = DmisCommand.SetToggleString (1, NORM_RELEARN, 0)
    ' Set Use Theoretical Vector = YES
    retval = DmisCommand.SetToggleString (2, USE_THEO, 0)

    Set DmisCommand = DmisCommands.Add(MOVE_CIRCULAR, TRUE)
    DmisCommand.Marked = TRUE
  • Set DmisCommand = DmisCommands.Add(BASIC_HIT, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Theoretical X = 0.0034
    retval = DmisCommand.PutText ("0.0034", THEO_X, 0)
    ' Set Theoretical Y = 1.7866
    retval = DmisCommand.PutText ("1.7866", THEO_Y, 0)
    ' Set Theoretical Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", THEO_Z, 0)
    ' Set Theoretical I = 0
    retval = DmisCommand.PutText ("0", THEO_I, 0)
    ' Set Theoretical J = 1
    retval = DmisCommand.PutText ("1", THEO_J, 0)
    ' Set Theoretical K = 0
    retval = DmisCommand.PutText ("0", THEO_K, 0)
    ' Set Measured X = 0.0033
    retval = DmisCommand.PutText ("0.0033", MEAS_X, 0)
    ' Set Measured Y = 1.8212
    retval = DmisCommand.PutText ("1.8212", MEAS_Y, 0)
    ' Set Measured Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", MEAS_Z, 0)
    ' Set Measured I = 0.0016691
    retval = DmisCommand.PutText ("0.0016691", MEAS_I, 0)
    ' Set Measured J = 0.9999986
    retval = DmisCommand.PutText ("0.9999986", MEAS_J, 0)
    ' Set Measured K = 0
    retval = DmisCommand.PutText ("0", MEAS_K, 0)
    ' Set Learn Mode = NORMAL
    retval = DmisCommand.SetToggleString (1, NORM_RELEARN, 0)
    ' Set Use Theoretical Vector = YES
    retval = DmisCommand.SetToggleString (2, USE_THEO, 0)

    Set DmisCommand = DmisCommands.Add(MOVE_CIRCULAR, TRUE)
    DmisCommand.Marked = TRUE

    Set DmisCommand = DmisCommands.Add(BASIC_HIT, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Theoretical X = -1.2846
    retval = DmisCommand.PutText ("-1.2846", THEO_X, 0)
    ' Set Theoretical Y = 1.2531
    retval = DmisCommand.PutText ("1.2531", THEO_Y, 0)
    ' Set Theoretical Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", THEO_Z, 0)
    ' Set Theoretical I = -0.7071068
    retval = DmisCommand.PutText ("-0.7071068", THEO_I, 0)
    ' Set Theoretical J = 0.7071068
    retval = DmisCommand.PutText ("0.7071068", THEO_J, 0)
    ' Set Theoretical K = 0
    retval = DmisCommand.PutText ("0", THEO_K, 0)
    ' Set Measured X = -1.3032
    retval = DmisCommand.PutText ("-1.3032", MEAS_X, 0)
    ' Set Measured Y = 1.2725
    retval = DmisCommand.PutText ("1.2725", MEAS_Y, 0)
    ' Set Measured Z = 0.1675
    retval = DmisCommand.PutText ("0.1675", MEAS_Z, 0)
    ' Set Measured I = -0.7155769
    retval = DmisCommand.PutText ("-0.7155769", MEAS_I, 0)
    ' Set Measured J = 0.698534
    retval = DmisCommand.PutText ("0.698534", MEAS_J, 0)
    End Sub

    Sub Part3

    ' Set Measured K = 0
    retval = DmisCommand.PutText ("0", MEAS_K, 0)
    ' Set Learn Mode = NORMAL
    retval = DmisCommand.SetToggleString (1, NORM_RELEARN, 0)
    ' Set Use Theoretical Vector = YES
    retval = DmisCommand.SetToggleString (2, USE_THEO, 0)

    Set DmisCommand = DmisCommands.Add(MOVE_CIRCULAR, TRUE)
    DmisCommand.Marked = TRUE

    Set DmisCommand = DmisCommands.Add(BASIC_HIT, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Theoretical X = -1.8181
    retval = DmisCommand.PutText ("-1.8181", THEO_X, 0)
    ' Set Theoretical Y = -0.0349
    retval = DmisCommand.PutText ("-0.0349", THEO_Y, 0)
    ' Set Theoretical Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", THEO_Z, 0)
    ' Set Theoretical I = -1
    retval = DmisCommand.PutText ("-1", THEO_I, 0)
    ' Set Theoretical J = 0
    retval = DmisCommand.PutText ("0", THEO_J, 0)
    ' Set Theoretical K = 0
    retval = DmisCommand.PutText ("0", THEO_K, 0)
    ' Set Measured X = -1.8209
    retval = DmisCommand.PutText ("-1.8209", MEAS_X, 0)
    ' Set Measured Y = -0.0337
    retval = DmisCommand.PutText ("-0.0337", MEAS_Y, 0)
    ' Set Measured Z = 0.1676
    retval = DmisCommand.PutText ("0.1676", MEAS_Z, 0)
    ' Set Measured I = -0.9998281
    retval = DmisCommand.PutText ("-0.9998281", MEAS_I, 0)
    ' Set Measured J = -0.0185432
    retval = DmisCommand.PutText ("-0.0185432", MEAS_J, 0)
    ' Set Measured K = 0
    retval = DmisCommand.PutText ("0", MEAS_K, 0)
    ' Set Learn Mode = NORMAL
    retval = DmisCommand.SetToggleString (1, NORM_RELEARN, 0)
    ' Set Use Theoretical Vector = YES
    retval = DmisCommand.SetToggleString (2, USE_THEO, 0)

    Set DmisCommand = DmisCommands.Add(MOVE_CIRCULAR, TRUE)
    DmisCommand.Marked = TRUE

    Set DmisCommand = DmisCommands.Add(BASIC_HIT, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Theoretical X = -1.2846
    retval = DmisCommand.PutText ("-1.2846", THEO_X, 0)
    ' Set Theoretical Y = -1.3229
    retval = DmisCommand.PutText ("-1.3229", THEO_Y, 0)
    ' Set Theoretical Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", THEO_Z, 0)
    ' Set Theoretical I = -0.7071068
    retval = DmisCommand.PutText ("-0.7071068", THEO_I, 0)
    ' Set Theoretical J = -0.7071068
    retval = DmisCommand.PutText ("-0.7071068", THEO_J, 0)
    ' Set Theoretical K = 0
    retval = DmisCommand.PutText ("0", THEO_K, 0)
    ' Set Measured X = -1.2689
    retval = DmisCommand.PutText ("-1.2689", MEAS_X, 0)
    ' Set Measured Y = -1.3062
    retval = DmisCommand.PutText ("-1.3062", MEAS_Y, 0)
    ' Set Measured Z = 0.1675
    retval = DmisCommand.PutText ("0.1675", MEAS_Z, 0)
    ' Set Measured I = -0.6968683
    retval = DmisCommand.PutText ("-0.6968683", MEAS_I, 0)
    ' Set Measured J = -0.7171992
    retval = DmisCommand.PutText ("-0.7171992", MEAS_J, 0)
    ' Set Measured K = 0
    retval = DmisCommand.PutText ("0", MEAS_K, 0)
    ' Set Learn Mode = NORMAL
    retval = DmisCommand.SetToggleString (1, NORM_RELEARN, 0)
    ' Set Use Theoretical Vector = YES
    retval = DmisCommand.SetToggleString (2, USE_THEO, 0)

    Set DmisCommand = DmisCommands.Add(MOVE_CIRCULAR, TRUE)
    DmisCommand.Marked = TRUE

    Set DmisCommand = DmisCommands.Add(BASIC_HIT, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Theoretical X = 0.0034
    retval = DmisCommand.PutText ("0.0034", THEO_X, 0)
    ' Set Theoretical Y = -1.8564
    retval = DmisCommand.PutText ("-1.8564", THEO_Y, 0)
    ' Set Theoretical Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", THEO_Z, 0)
    ' Set Theoretical I = 0
    retval = DmisCommand.PutText ("0", THEO_I, 0)
    ' Set Theoretical J = -1
    retval = DmisCommand.PutText ("-1", THEO_J, 0)
    ' Set Theoretical K = 0
    retval = DmisCommand.PutText ("0", THEO_K, 0)
    ' Set Measured X = 0.003
    retval = DmisCommand.PutText ("0.003", MEAS_X, 0)
    ' Set Measured Y = -1.8217
    retval = DmisCommand.PutText ("-1.8217", MEAS_Y, 0)
    ' Set Measured Z = 0.1676
    retval = DmisCommand.PutText ("0.1676", MEAS_Z, 0)
    ' Set Measured I = 0.0014683
    retval = DmisCommand.PutText ("0.0014683", MEAS_I, 0)
    ' Set Measured J = -0.9999989
    retval = DmisCommand.PutText ("-0.9999989", MEAS_J, 0)
    ' Set Measured K = 0
    retval = DmisCommand.PutText ("0", MEAS_K, 0)
    ' Set Learn Mode = NORMAL
    retval = DmisCommand.SetToggleString (1, NORM_RELEARN, 0)
    ' Set Use Theoretical Vector = YES
    retval = DmisCommand.SetToggleString (2, USE_THEO, 0)

    Set DmisCommand = DmisCommands.Add(MOVE_CIRCULAR, TRUE)
    DmisCommand.Marked = TRUE

    Set DmisCommand = DmisCommands.Add(BASIC_HIT, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Theoretical X = 1.2914
    retval = DmisCommand.PutText ("1.2914", THEO_X, 0)
    ' Set Theoretical Y = -1.3229
    retval = DmisCommand.PutText ("-1.3229", THEO_Y, 0)
    ' Set Theoretical Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", THEO_Z, 0)
    ' Set Theoretical I = 0.7071068
    retval = DmisCommand.PutText ("0.7071068", THEO_I, 0)
    ' Set Theoretical J = -0.7071068
    retval = DmisCommand.PutText ("-0.7071068", THEO_J, 0)
    ' Set Theoretical K = 0
    retval = DmisCommand.PutText ("0", THEO_K, 0)
    ' Set Measured X = 1.2723
    retval = DmisCommand.PutText ("1.2723", MEAS_X, 0)
    ' Set Measured Y = -1.3034
    retval = DmisCommand.PutText ("-1.3034", MEAS_Y, 0)
    ' Set Measured Z = 0.1674
    retval = DmisCommand.PutText ("0.1674", MEAS_Z, 0)
    ' Set Measured I = 0.6984213
    retval = DmisCommand.PutText ("0.6984213", MEAS_I, 0)
    ' Set Measured J = -0.7156869
    retval = DmisCommand.PutText ("-0.7156869", MEAS_J, 0)
    ' Set Measured K = 0
    retval = DmisCommand.PutText ("0", MEAS_K, 0)
    ' Set Learn Mode = NORMAL
    retval = DmisCommand.SetToggleString (1, NORM_RELEARN, 0)
    ' Set Use Theoretical Vector = YES
    retval = DmisCommand.SetToggleString (2, USE_THEO, 0)

    Set DmisCommand = DmisCommands.Add(END_MEASURED_FEATURE, TRUE)
    DmisCommand.Marked = TRUE
  • Thank you for the help and the insight to what this program is actually doing. I really appreciate it.
  • First you are looking for preset command ID's, if none of these match, you check if the command is a feature and if it is, you fetch the MeasDiam.
    What if the feature in question is a line or a plane? I don't think they have the property MeasDiam since these are not diameters. Chances are that it will error out...

    The exported program is basically now a script. If you execute the script within PC-DMIS, it will (should) create the program you exported.

    If you once found a circle feature command through your code, you can get the diameter through this:

    myDiam = PCDCommand.GetText(MEAS_DIAM, 0)


    And fetch the X-coordinate (as an example) through this:

    mX = PCDCommand.GetText(MEAS_X, 0) ' measured
    tX = PCDCommand.GetText(THEO_X, 0) ' theoretical
  • Thank you. I will play with this and see what I can get to work. I can't say enough how much I appreciate your help.