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...
  • This is what a PCD tracefield command looks like in basic:

    Set DmisCommand = DmisCommands.Add(TRACEFIELD, TRUE)    DmisCommand.Marked = TRUE
      ' Set Name  = Lot #
        retval = DmisCommand.PutText ("Lot #", TRACE_NAME, 0)
      ' Set Value  = 
        retval = DmisCommand.PutText ("", TRACE_VALUE, 0)
      ' Set Value Limit  = 15
        retval = DmisCommand.PutText ("15", TRACE_VALUE_LIMIT, 0)
      Result = DmisCommand.SetExpression("LOT", TRACE_VALUE, 0)


    Just have to figure out how to look for a specific TRACE_NAME then get the TRACE_VALUE.
  • This is what a PCD tracefield command looks like in basic:

    Set DmisCommand = DmisCommands.Add(TRACEFIELD, TRUE)    DmisCommand.Marked = TRUE
      ' Set Name  = Lot #
        retval = DmisCommand.PutText ("Lot #", TRACE_NAME, 0)
      ' Set Value  = 
        retval = DmisCommand.PutText ("", TRACE_VALUE, 0)
      ' Set Value Limit  = 15
        retval = DmisCommand.PutText ("15", TRACE_VALUE_LIMIT, 0)
      Result = DmisCommand.SetExpression("LOT", TRACE_VALUE, 0)


    Just have to figure out how to look for a specific TRACE_NAME then get the TRACE_VALUE.


    Yea I exported the basic code to get a look at the commands, but there's not a command for "getting" the value from the tracefield.

    I tried:

    "Cmd.GetTracefield.Value("blah..blah") --- nothing
    Set variable = Part.TracefieldValue blah blah --- nothing

    I'll keep trying other commands until I get it

    Thanks for the help...
  • Take a look at this thread: http://www.pcdmisforum.com/showthread.php?26953-Script-to-make-a-change-in-all-programs

    I posted some examples of both getting and setting values for some other commands, the syntax will be nearly the same for what you're doing.
  • Sub Main
    
    'Declares the File System Object And Instantiates it
    Dim  objFSO
    Set  objFSO = CreateObject("Scripting.FileSystemObject")
    Dim Count As Integer
    
    
    'Declares PC-DMIS As the Active Program/Application
    Dim PCDApp, Part, Cmds, Cmd, TCmd As Object
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set Part = PCDApp.ActivePartProgram
    Set Cmds = Part.Commands
    
    For Each Cmd In Cmds
           If Cmd.IsTraceFieldCommand Then
               Set TCmd = Cmd.TraceFieldCommand
               
               Count=Count+1
           End If 
         Next Cmd


    Am I on the right track with this? I keep getting a type mismatch error with the If line ("If Cmd.IsTraceFieldCommand Then")
  • Take a look at this thread: http://www.pcdmisforum.com/showthread.php?26953-Script-to-make-a-change-in-all-programs

    I posted some examples of both getting and setting values for some other commands, the syntax will be nearly the same for what you're doing.


    I think that's way above my understanding level to interpolate what I need from those examples.
  • Sub Main
    
    'Declares the File System Object And Instantiates it
    Dim  objFSO
    Set  objFSO = CreateObject("Scripting.FileSystemObject")
    Dim Count As Integer
    
    
    'Declares PC-DMIS As the Active Program/Application
    Dim PCDApp, Part, Cmds, Cmd, TCmd As Object
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set Part = PCDApp.ActivePartProgram
    Set Cmds = Part.Commands
    
    For Each Cmd In Cmds
           [COLOR=#ff0000]If Cmd.Type = 191 Then 'Think this is the tracefield type number
    
                TCmd = Cmd.gettext(TRACE_VALUE, 1)[/COLOR]
               
               Count=Count+1
           End If 
         Next Cmd


    Am I on the right track with this? I keep getting a type mismatch error with the If line ("If Cmd.IsTraceFieldCommand Then")


    Something like this maybe??
  • Almost every Set or Put command has a Get equivalent. See the basic helpfile.
  • if Cmd.IsTraceField Then


    This command gives me a type mismatch error.
  • Dim PCDApp, Part, Cmds, Cmd, TCmd, TCmds As Object
            PCDApp = CreateObject("PCDLRN.Application")
            Part = PCDApp.ActivePartProgram
            Cmds = Part.Commands
            Cmd = Part.Command
            TCmds = Part.TraceFieldCommands
            TCmd = Part.TraceFieldCommand
            Dim VSERIALNUMBER As Object
    
    
            For Each TCmd In TCmds
                If TCmd.Name = "SERIALNUMBER" Then
                    VSERIALNUMBER = TCmd.Value
    
                End If
    
            Next
    

    I've gotten this far with help from the Object Browser in VB. Now it is throwing an object error "object with variable block not set" at the
    "TCmds = Part.TraceFieldCommands" line.