hexagon logo

Change Tracefield...

Hello!

Trying to change a tracefield value using VBA, it is behaving weirdly. I can change the internal value, but it still has the old string written with quote marks entered in the edit-window and that does not change. Upon execution of the tracefield it then resets to the old string. Anyone encountered this? The change works if there is a text without quotation marks. I tried the value-function and setexpression, neither works on the quote-text.
Parents
  • hello,

    thats works for me in v2021.2 sp4
    with or without quotation

    Sub Main()
    Dim DmisApp As Object
    Dim DmisPart As Object
    Dim DmisCommands As Object
    Dim DmisCommand As Object
    
    Set DmisApp = CreateObject("PCDLRN.Application")
    Set DmisPart = DmisApp.ActivePartProgram
    Set DmisCommands = DmisPart.Commands
    
    For Each DmisCommand In DmisCommands
    If DmisCommand.Type = TRACEFIELD Then
    retVal = DmisCommand.PutText("should work", TRACE_VALUE, 0)
    Exit For
    End If
    Next DmisCommand
    
    DmisPart.RefreshPart
    End Sub
    



    if you want to set quotation within pcDMIS use something like this
    Sub Main()
    Dim DmisApp As Object
    Dim DmisPart As Object
    Dim DmisCommands As Object
    Dim DmisCommand As Object
    
    Set DmisApp = CreateObject("PCDLRN.Application")
    Set DmisPart = DmisApp.ActivePartProgram
    Set DmisCommands = DmisPart.Commands
    
    For Each DmisCommand In DmisCommands
    If DmisCommand.Type = TRACEFIELD Then
    retVal = DmisCommand.PutText("should work", TRACE_VALUE, 0)
    retVal = DmisCommand.SetExpression("""should work""", TRACE_VALUE, 0)
    Exit For
    End If
    Next DmisCommand
    
    DmisPart.RefreshPart
    End Sub
    
Reply
  • hello,

    thats works for me in v2021.2 sp4
    with or without quotation

    Sub Main()
    Dim DmisApp As Object
    Dim DmisPart As Object
    Dim DmisCommands As Object
    Dim DmisCommand As Object
    
    Set DmisApp = CreateObject("PCDLRN.Application")
    Set DmisPart = DmisApp.ActivePartProgram
    Set DmisCommands = DmisPart.Commands
    
    For Each DmisCommand In DmisCommands
    If DmisCommand.Type = TRACEFIELD Then
    retVal = DmisCommand.PutText("should work", TRACE_VALUE, 0)
    Exit For
    End If
    Next DmisCommand
    
    DmisPart.RefreshPart
    End Sub
    



    if you want to set quotation within pcDMIS use something like this
    Sub Main()
    Dim DmisApp As Object
    Dim DmisPart As Object
    Dim DmisCommands As Object
    Dim DmisCommand As Object
    
    Set DmisApp = CreateObject("PCDLRN.Application")
    Set DmisPart = DmisApp.ActivePartProgram
    Set DmisCommands = DmisPart.Commands
    
    For Each DmisCommand In DmisCommands
    If DmisCommand.Type = TRACEFIELD Then
    retVal = DmisCommand.PutText("should work", TRACE_VALUE, 0)
    retVal = DmisCommand.SetExpression("""should work""", TRACE_VALUE, 0)
    Exit For
    End If
    Next DmisCommand
    
    DmisPart.RefreshPart
    End Sub
    
Children
No Data