hexagon logo

VB Script, Using PutText to enter an expression

I want to write a script that can modify the THEO and TARG values of a feature to be an expression, such as "1+0" or "2*VX+4". So far I can change the values to other values but if I give it an expression it always seems to evaluate it first and insert the result rather than the expression itself.

Not sure if what I want to do is possible but after scouring the forum for any examples I am sure that if it is possible someone on here will know how to do it.
Parents


  • code
    extracts theos and shows on screen


    Sub Main()
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPARTPROGRAMS = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    Dim cmd As Object
    Dim fcntr As Integer
    Dim FeatureList$(99999)
    Dim TX, TY, TZ, NewTX, NewTY, NewTZ As Variant
    
    fcntr = 0
    
    For Each cmd in PCDCommands
    If cmd.IsDCCFeature or cmd.IsMeasuredFeature Then
    FeatureList(fcntr) = cmd.id
    
    MSG = "feature ID = " & FeatureList(fcntr)
    
    TX = cmd.GetText(THEO_X, 0)
    ​​​​​​​TY = cmd.GetText(THEO_Y, 0)
    ​​​​​​​TZ = cmd.GetText(THEO_Z, 0)
    NewTX = TX & "+0"
    NewTY = TY & "+0"
    NewTZ = TZ & "+0"
    
    MSG = MSG & chr(10) & chr(10) & "XTheo = " &TX
    MSG = MSG & chr(10) & chr(10) & "YTheo = " &TY
    MSG = MSG & chr(10) & chr(10) & "ZTheo = " &TZ
    MSG = MSG & chr(10) & chr(10) & "NewXTheo = " &NewTX
    MSG = MSG & chr(10) & chr(10) & "NewYTheo = " &NewTY
    MSG = MSG & chr(10) & chr(10) & "NewZTheo = " &NewTZ
    
    MsgBox MSG
    
    End If
    
    Next cmd
    
    Set PCDApp = nothing
    Set PCDPartPrograms = nothing
    Set PCDPartProgram = nothing
    


    I'm stumped! I get the same thing! I am not sure why it thinks it's in a different alignment.
Reply


  • code
    extracts theos and shows on screen


    Sub Main()
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPARTPROGRAMS = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    Dim cmd As Object
    Dim fcntr As Integer
    Dim FeatureList$(99999)
    Dim TX, TY, TZ, NewTX, NewTY, NewTZ As Variant
    
    fcntr = 0
    
    For Each cmd in PCDCommands
    If cmd.IsDCCFeature or cmd.IsMeasuredFeature Then
    FeatureList(fcntr) = cmd.id
    
    MSG = "feature ID = " & FeatureList(fcntr)
    
    TX = cmd.GetText(THEO_X, 0)
    ​​​​​​​TY = cmd.GetText(THEO_Y, 0)
    ​​​​​​​TZ = cmd.GetText(THEO_Z, 0)
    NewTX = TX & "+0"
    NewTY = TY & "+0"
    NewTZ = TZ & "+0"
    
    MSG = MSG & chr(10) & chr(10) & "XTheo = " &TX
    MSG = MSG & chr(10) & chr(10) & "YTheo = " &TY
    MSG = MSG & chr(10) & chr(10) & "ZTheo = " &TZ
    MSG = MSG & chr(10) & chr(10) & "NewXTheo = " &NewTX
    MSG = MSG & chr(10) & chr(10) & "NewYTheo = " &NewTY
    MSG = MSG & chr(10) & chr(10) & "NewZTheo = " &NewTZ
    
    MsgBox MSG
    
    End If
    
    Next cmd
    
    Set PCDApp = nothing
    Set PCDPartPrograms = nothing
    Set PCDPartProgram = nothing
    


    I'm stumped! I get the same thing! I am not sure why it thinks it's in a different alignment.
Children
No Data