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.
Parents
  • So here is my latest attempt at getting that measured plane's output out of the PCDMIS brain and into the WinSPC one.
    	'PCDMIS commands
          Dim ObjApp As Object
          Dim ObjCmds As Object
          Dim ObjCmd As Object
          Dim ObjPart As Object
          Dim ObjDimCmd 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 StrDimDiameter As String
    	Dim StrDimPlane As String
    	Dim MeasZ As String
    	Dim Clock As String
    	Dim Part As String
    	Dim DimMeas As Double
    	Dim MyComment As Double
    	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.IsComment Then
        If ObjCmd.CommentCommand.CommentType = PCD_COMMENT_INPUT Then 
          If ObjCmd.ID = "C1" Then
            StrC1 = ObjCmd.CommentCommand.Input
          End If
        End If
      End If
    If ObjCmd.IsComment Then
        If ObjCmd.CommentCommand.CommentType = PCD_COMMENT_INPUT Then 
          If ObjCmd.ID = "C2" Then
            StrC2 = ObjCmd.CommentCommand.Input
          End If
        End If
      End If
    
    If ObjCmd.IsDimension Then
    Set ObjDimCmd = ObjCmd.DimensionCommand
    StrDimID = ObjDimCmd.ID
    StrDimFeature = ObjDimCmd.Feat1
    StrDimType = ObjCmd.Type
    StrDimNominal = ObjDimCmd.Nominal
    StrDimUTol = ObjDimCmd.Plus
    StrDimLTol = ObjDimCmd.Minus
    StrDimMeasure = ObjDimCmd.Measured
    If (StrDimType = "DIMENSION_START_LOCATION" Or StrDimType = "DIMENSION_Z_LOCATION") Then 
    StrDimPlane=ObjCmd.GetText(DIM_MEASURED,0)
    End If
    ElseIf ObjCmd.IsFeature Then
    StrDimID = ObjCmd.FeatureCommand.ID
    StrDimDiameter = ObjCmd.FeatureCommand.MeasDiam
    MeasZ = ObjCmd.GetText(MEAS_Z,0)
    
    End If
    
    		     
        If StrDimID = "CIR2- OUTER CIRCLE ABOVE STEP" Then MyReading1 = StrDimDiameter
        If StrDimID = "ROUNDNESS CIRC2" Then MyReading2 = StrDimMeasure
        If StrDimID = "CIR3- RADIUS OF STEP ON OUTER EDGE" Then MyReading3 = StrDimDiameter
        If StrDimID = "CIR6- OUTER CIRCLE BELOW STEP" Then MyReading4 = StrDimDiameter
        If StrDimID = "ROUNDNESS CIRC6" Then MyReading5 = StrDimMeasure
        If StrDimID = "CONC1" Then MyReading6 = StrDimMeasure
        If StrDimID = "CONC2" Then MyReading7 = StrDimMeasure
        If StrDimID = "POINT 1Z" Then MyReading8 = StrDimMeasure
        If StrDimID = "POINT 2Z" Then MyReading9 = StrDimMeasure
        If StrDimID = "POINT 3Z" Then MyReading10 = StrDimMeasure
        If StrDimID = "POINT 4Z" Then MyReading11 = StrDimMeasure
        If StrDimID = "PLANE4 Z" Then MyReading12 = StrDimMeasure
        If StrDimID = "PLANE5- COMBINATION OF POINT 1 2 3 4 ON STEP" Then MyReading13 = MeasZ
        If StrDimID = "POINT5Z" Then MyReading14 = MeasZ
        If StrDimID = "POINT6Z" Then MyReading15 = MeasZ
        If StrDimID = "POINT7Z" Then MyReading16 = MeasZ
        If StrDimID = "POINT8Z" Then MyReading17 = MeasZ
    	Next
    

    from everything I have read, this should work, but of course so far most of the stuff I have tried should work. Smiley. So frustrated.
Reply
  • So here is my latest attempt at getting that measured plane's output out of the PCDMIS brain and into the WinSPC one.
    	'PCDMIS commands
          Dim ObjApp As Object
          Dim ObjCmds As Object
          Dim ObjCmd As Object
          Dim ObjPart As Object
          Dim ObjDimCmd 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 StrDimDiameter As String
    	Dim StrDimPlane As String
    	Dim MeasZ As String
    	Dim Clock As String
    	Dim Part As String
    	Dim DimMeas As Double
    	Dim MyComment As Double
    	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.IsComment Then
        If ObjCmd.CommentCommand.CommentType = PCD_COMMENT_INPUT Then 
          If ObjCmd.ID = "C1" Then
            StrC1 = ObjCmd.CommentCommand.Input
          End If
        End If
      End If
    If ObjCmd.IsComment Then
        If ObjCmd.CommentCommand.CommentType = PCD_COMMENT_INPUT Then 
          If ObjCmd.ID = "C2" Then
            StrC2 = ObjCmd.CommentCommand.Input
          End If
        End If
      End If
    
    If ObjCmd.IsDimension Then
    Set ObjDimCmd = ObjCmd.DimensionCommand
    StrDimID = ObjDimCmd.ID
    StrDimFeature = ObjDimCmd.Feat1
    StrDimType = ObjCmd.Type
    StrDimNominal = ObjDimCmd.Nominal
    StrDimUTol = ObjDimCmd.Plus
    StrDimLTol = ObjDimCmd.Minus
    StrDimMeasure = ObjDimCmd.Measured
    If (StrDimType = "DIMENSION_START_LOCATION" Or StrDimType = "DIMENSION_Z_LOCATION") Then 
    StrDimPlane=ObjCmd.GetText(DIM_MEASURED,0)
    End If
    ElseIf ObjCmd.IsFeature Then
    StrDimID = ObjCmd.FeatureCommand.ID
    StrDimDiameter = ObjCmd.FeatureCommand.MeasDiam
    MeasZ = ObjCmd.GetText(MEAS_Z,0)
    
    End If
    
    		     
        If StrDimID = "CIR2- OUTER CIRCLE ABOVE STEP" Then MyReading1 = StrDimDiameter
        If StrDimID = "ROUNDNESS CIRC2" Then MyReading2 = StrDimMeasure
        If StrDimID = "CIR3- RADIUS OF STEP ON OUTER EDGE" Then MyReading3 = StrDimDiameter
        If StrDimID = "CIR6- OUTER CIRCLE BELOW STEP" Then MyReading4 = StrDimDiameter
        If StrDimID = "ROUNDNESS CIRC6" Then MyReading5 = StrDimMeasure
        If StrDimID = "CONC1" Then MyReading6 = StrDimMeasure
        If StrDimID = "CONC2" Then MyReading7 = StrDimMeasure
        If StrDimID = "POINT 1Z" Then MyReading8 = StrDimMeasure
        If StrDimID = "POINT 2Z" Then MyReading9 = StrDimMeasure
        If StrDimID = "POINT 3Z" Then MyReading10 = StrDimMeasure
        If StrDimID = "POINT 4Z" Then MyReading11 = StrDimMeasure
        If StrDimID = "PLANE4 Z" Then MyReading12 = StrDimMeasure
        If StrDimID = "PLANE5- COMBINATION OF POINT 1 2 3 4 ON STEP" Then MyReading13 = MeasZ
        If StrDimID = "POINT5Z" Then MyReading14 = MeasZ
        If StrDimID = "POINT6Z" Then MyReading15 = MeasZ
        If StrDimID = "POINT7Z" Then MyReading16 = MeasZ
        If StrDimID = "POINT8Z" Then MyReading17 = MeasZ
    	Next
    

    from everything I have read, this should work, but of course so far most of the stuff I have tried should work. Smiley. So frustrated.
Children
No Data