hexagon logo

OLE Automation with TP

Now that this has been tested by the operators on the floor, I have a script for the OLE with true position.

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 StrC1 As String
	Dim StrC2 As String
	
    	Dim StrDimID As String
	Dim StrDimMeasure 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

      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
		If Len(ObjDimCmd.ID) > 0 Then
   		PrevID = StrDimID 
   		StrDimID = ObjDimCmd.ID 
		End If 
StrDimMeasure = ObjDimCmd.Measured
StrAx = ObjDimCmd.AxisLetter
StrDev = ObjDimCmd.Deviation
End If  

		     
    If StrDimID = "CIRC1 DIA" And StrAx = "D" Then MyReading1 = StrDimMeasure
    If StrDimID = "CIRC4 DIA" And StrAx = "D" Then MyReading2 = StrDimMeasure
    If StrDimID = "CIRC5 TRUE POSTION" And StrAx = "Y" Then MyReading3 = StrDimMeasure
    If StrDimID = "CIRC5 TRUE POSTION" And StrAx = "Z" Then MyReading4 = StrDimMeasure
    If StrDimID = "CIRC5 TRUE POSTION" And StrAx = "DF" Then MyReading5 = StrDimMeasure
    If StrDimID = "CIRC5 TRUE POSTION" And StrAx = "TP" Then MyReading6 = StrDev
    If StrDimID = "CIRC6 DIA" And StrAx = "D" Then MyReading7 = StrDimMeasure
    If StrDimID = "CIRC7 TRUE POSITION" And StrAx ="Y" Then MyReading8 = StrDimMeasure
    If StrDimID = "CIRC7 TRUE POSITION" And StrAx ="Z" Then MyReading9 = StrDimMeasure
    If StrDimID = "CIRC7 TRUE POSITION" And StrAx ="DF" Then MyReading10 = StrDimMeasure
 	Next


The only weird thing to this is that if you have an axis letter of M, do not specify the axis letter in your code, for example:
If StrDimID = "DIST1" Then MyReading1 = StrDimMeasure

I have not been able to test to see if this works with FCF's as well since I have not seen a program that uses both TP and FCF yet, but there is another OLE that can pull the FCF code but uses dimensions and features together and this one strickly uses dimensions.

Don't forget to call out the variables that you use to open the second application and then place your information where you desire it to go after the next command.

Thank you to vtp.se for the help with getting the ID to follow through to all the commands. It made getting this done so much simpler.
Parents Reply Children
No Data