hexagon logo

Tracefields and Scripts

Anyone out there know how to retrieve a Tracefield Value from a part program in a script? Can't quite find the right command...
Parents
  • You need to help us help you. . . Please post your code here so we can see if we recognize a syntax error, or code error. Also a little more detail on the "No Luck. . ." might be helpful. Did it run and not do anything? Did it return an error? Did it do anything but just not what you wanted?


    Sub Main
    
    
    
    'Declares the File System Object And Instantiates it
     Dim objFSO
     objFSO = CreateObject("Scripting.FileSystemObject")
            
    
    
    'Declares PC-DMIS As the Active Program/Application
    Dim PCDApp As Object
    Dim Part As Object
    Dim Cmds  As Object
    Dim Cmd As Object
    Dim TCmd As Object
    Dim TCmds As Object
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set Part = PCDApp.ActivePartProgram
    Set Cmds = Part.Commands
    Dim  VSERIALNUMBER As Object
    
        For Each Cmd In Cmds
              If Cmd.IsTraceField Then
              Set TCmd = Cmd.TraceFieldCommand
              End If
    
              If TCmd.Name = "Serial Number" Then (this is line 28)
              VSERIALNUMBER = TCmd.Value
        End If
    
    Next Cmd
    
    
    End Sub
    


    Runtime Error on line:28 - Object variable or With block variable not set
Reply
  • You need to help us help you. . . Please post your code here so we can see if we recognize a syntax error, or code error. Also a little more detail on the "No Luck. . ." might be helpful. Did it run and not do anything? Did it return an error? Did it do anything but just not what you wanted?


    Sub Main
    
    
    
    'Declares the File System Object And Instantiates it
     Dim objFSO
     objFSO = CreateObject("Scripting.FileSystemObject")
            
    
    
    'Declares PC-DMIS As the Active Program/Application
    Dim PCDApp As Object
    Dim Part As Object
    Dim Cmds  As Object
    Dim Cmd As Object
    Dim TCmd As Object
    Dim TCmds As Object
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set Part = PCDApp.ActivePartProgram
    Set Cmds = Part.Commands
    Dim  VSERIALNUMBER As Object
    
        For Each Cmd In Cmds
              If Cmd.IsTraceField Then
              Set TCmd = Cmd.TraceFieldCommand
              End If
    
              If TCmd.Name = "Serial Number" Then (this is line 28)
              VSERIALNUMBER = TCmd.Value
        End If
    
    Next Cmd
    
    
    End Sub
    


    Runtime Error on line:28 - Object variable or With block variable not set
Children
No Data