hexagon logo

OLE Automation that works with FCF

Instead of making people slog through 13 pages of questions and failed code samples, I am posting this here.

I only pulled the deviation from the FCF dimensions that we use since that is the same as the measurement. But this one does work and gets what we needed.

'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
	

	'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 StrDimDev As String
	Dim StrAct As String
	Dim StrDimMeasure As String
	Dim StrDimDiameter As String
	Dim MeasZ As String
	Dim FcfMeas 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.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 = ObjDimCmd.AxisLetter
StrDimNominal = ObjDimCmd.Nominal
StrDimDev = ObjDimCmd.Deviation
StrDimUTol = ObjDimCmd.Plus
StrDimLTol = ObjDimCmd.Minus
StrDimMeasure = ObjDimCmd.Measured
StrDimAct = StrDimNominal + StrDimDev
ElseIf ObjCmd.IsFeature Then
StrDimID = ObjCmd.FeatureCommand.ID
StrDimDiameter = ObjCmd.FeatureCommand.MeasDiam
ElseIf ObjCmd.Type = 184 Then
  FcfMeas = ObjCmd.GetFieldValue(LINE2_DEV,1)
End If

		     
    If StrDimID = "CIR1- DIA UNDER GROOVE" Then MyReading1 = StrDimDiameter
    If StrDimID = "CIRC 1 ROUNDNESS" Then MyReading2 = FcfMeas
    If StrDimID = "CIR2- DIA OF GROOVE" Then MyReading3 = StrDimDiameter
    If StrDimID = "CIRC 2 ROUNDNESS" Then MyReading4 = FcfMeas
    If StrDimID = "CIR3- DIA ABOVE GROOVE" Then MyReading5 = StrDimDiameter
    If StrDimID = "CIRC 3 ROUNDNESS" Then MyReading6 = FcfMeas
    	Next