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.
  • If you have notes on how to do it at work, when you get there, I would appreciate knowing how those are gotten. I did try one thing, but it didn't work. It may be that I just need to fine tune it or I could be on the wrong path completely. I'll play with it for a bit still and see how I do, but any guidance you can provide would be helpful.
  • Comment input

    This is what I currently have:
    If ObjCmd.IsComment Then
    StrDimID = ObjCmd.CommentCommand.ID
    Clock = ObjCmd.CommentCommand.Input

    And this is what I have tried:
    Clock = ObjCmd.GetText(COMMENT_TYPE,0)
    Clock = ObjCmd.GetText(COMMENT_FIELD, 1)
    Clock = ObjCmd.GetText(OUTPUT_TYPE, 0)


    So far all of these have returned a 0 for me. Any suggestions on what else to try to get that operator input to export into the SPC software?
  • Also tried
    Clock = ObjCmd.GetText (INPUT_TYPE,0)
    Clock = ObjCmd.GetText (INPUT_TYPE,2)
    Clock = ObjCmd.GetText (COMMENT_TYPE,2)


    I keep thinking that I am close, but I can't quite get there.
  • These also do not work:

    Clock = ObjCmd.GetText(COMMENT_FIELD,2)
    Clock = ObjCmd.GetText(OUTPUT_TYPE,2)
    Disappointed
  • These also do not work:

    Clock = ObjCmd.GetText(COMMENT_FIELD,2)
    Clock = ObjCmd.GetText(OUTPUT_TYPE,2)
    Disappointed


    Here is how I would handle this:

    If ObjCmd.IsComment Then
        If ObjCmd.CommentCommand.CommentType = PCD_COMMENT_INPUT Then 
          If ObjCmd.ID = "CLKNBR" Then
            strClkNbr = ObjCmd.CommentCommand.Input
          End If
        End If
      End If
    



    I tested this using a COMMENT/INPUT that looks like this:
    CLKNBR     =COMMENT/INPUT,NO,FULL SCREEN=NO,
                'Enter something'
    
  • Thank you so much, DJAMS. This works awesome. I didn't know that I needed to declare the comment type. That is what I was missing. Slight smile I appreciate it.
  • I have these two parts that are giving me a hard time with similar code, as follows:
    Set DmisCommand = DmisCommands.Add(DIMENSION_START_LOCATION, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Id = PLANE4 Z
    retval = DmisCommand.PutText ("PLANE4 Z", ID, 0)
    ' Set Reference Id = PLANE4- TOP SURFACE OF BAFFLE
    retval = DmisCommand.PutText ("PLANE4- TOP SURFACE OF BAFFLE", 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.000083
    retval = DmisCommand.PutText ("0.000083", STANDARD_DEVIATION, 0)

    Set DmisCommand = DmisCommands.Add(DIMENSION_Z_LOCATION, TRUE)
    DmisCommand.Marked = TRUE
    ' Set Nominal = 0.5100
    retval = DmisCommand.PutText (" 0.5100", NOMINAL, 0)
    ' Set Measured = 0.5124
    retval = DmisCommand.PutText (" 0.5124", DIM_MEASURED, 0)
    ' Set Plus Tolerance = 0.0300
    retval = DmisCommand.PutText (" 0.0300", F_PLUS_TOL, 0)
    ' Set Minus Tolerance = 0.0300
    retval = DmisCommand.PutText (" 0.0300", F_MINUS_TOL, 0)
    ' Set Max = 0.5139
    retval = DmisCommand.PutText (" 0.5139", DIM_MAX, 0)
    ' Set Min = 0.5102
    retval = DmisCommand.PutText (" 0.5102", DIM_MIN, 0)
    ' Set Deviation = 0.0024
    retval = DmisCommand.PutText (" 0.0024", DIM_DEVIATION, 0)
    ' Set Out Tol = 0.0000
    retval = DmisCommand.PutText (" 0.0000", DIM_OUTTOL, 0)

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

    I currently have it in the program as: If StrDimID = "PLANE4 Z" Then MyReading12 = MeasZ but it returns a value that is half of what is expected.

    I looked for the dimension_z_location command in the forum and I found this thread: http://www.pcdmisforum.com/showthread.php?3751-Accessing-FCF-True-Position-in-VB&highlight=dimension_z_location and part of me thinks that there is something in there that may help but not sure if that is exactly what I looking for. Any thoughts?
  • So I have played with the above problem and everything I have tried so far is simply not working. Here is an example, that I sort of based off the solution that DJAMS offered up.

    If ObjCmd = DIMENSION_Z_LOCATION Then
    If ObjCmd.ID = "PLANE4 Z" Then
    DimMeas = ObjCmd.Measured
    End If
    End If

    And I have tried
    DimMeasured = ObjCmd.DimensionCommand.Measured
    ObjCmd.GetText(DIM_MEASURED,0)
    ObjCmd.GetText(MEAS_Z,0)
    And a few more that I simply can't remember right now.

    Maybe I am thinking too simply?
  • Would the GetCommandText or GetCommandField options give me what I need? Is the structure similar to what I am already doing?
  • So I have played with the above problem and everything I have tried so far is simply not working. Here is an example, that I sort of based off the solution that DJAMS offered up.

    If ObjCmd = DIMENSION_Z_LOCATION Then
    If ObjCmd.ID = "PLANE4 Z" Then
    DimMeas = ObjCmd.Measured
    End If
    End If


    This should work:

    If ObjCmd[COLOR=#ff0000].Type[/COLOR] = DIMENSION_Z_LOCATION Then
      If ObjCmd.ID = "PLANE4 Z" Then
        DimMeas = ObjCmd[COLOR=#ff0000].DimensionCommand[/COLOR].Measured
      End If
    End If