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
  • A snippet from one of my scripts:

    Set PCDCommand = PCDCommands.Add (GENERIC_CONSTRUCTION, True)
      PCDCommand.Marked = True
      retval = PCDCommand.SetExpression ("0+0", THEO_X, 0)
      retval = PCDCommand.SetExpression ("0+" & DLG.CheckBox_1, THEO_Y, 0)
      retval = PCDCommand.SetExpression ("0+0", THEO_Z, 0)
      retval = PCDCommand.SetExpression ("0+0", THEO_I, 0)
      retval = PCDCommand.SetExpression ("0+0", THEO_J, 0)
      retval = PCDCommand.SetExpression ("0+1", THEO_K, 0)
      retval = PCDCommand.PutText (Diameter, THEO_DIAM, 0)
    
      retval = PCDCommand.SetExpression ("0+0", MEAS_X, 0)
      retval = PCDCommand.SetExpression ("0+" & DLG.CheckBox_1, MEAS_Y, 0)
      retval = PCDCommand.SetExpression ("0+0", MEAS_Z, 0)
      retval = PCDCommand.SetExpression ("0+0", MEAS_I, 0)
      retval = PCDCommand.SetExpression ("0+0", MEAS_J, 0)
      retval = PCDCommand.SetExpression ("0+1", MEAS_K, 0)
      retval = PCDCommand.PutText (Diameter, MEAS_DIAM, 0)
      retval = PCDCommand.PutText ("CDATA", ID, 0)
      retval = PCDCommand.SetToggleString (4, GEN_FEAT_TYPE, 0)


    SetExpression is what you want to be using, not PutText.
Reply
  • A snippet from one of my scripts:

    Set PCDCommand = PCDCommands.Add (GENERIC_CONSTRUCTION, True)
      PCDCommand.Marked = True
      retval = PCDCommand.SetExpression ("0+0", THEO_X, 0)
      retval = PCDCommand.SetExpression ("0+" & DLG.CheckBox_1, THEO_Y, 0)
      retval = PCDCommand.SetExpression ("0+0", THEO_Z, 0)
      retval = PCDCommand.SetExpression ("0+0", THEO_I, 0)
      retval = PCDCommand.SetExpression ("0+0", THEO_J, 0)
      retval = PCDCommand.SetExpression ("0+1", THEO_K, 0)
      retval = PCDCommand.PutText (Diameter, THEO_DIAM, 0)
    
      retval = PCDCommand.SetExpression ("0+0", MEAS_X, 0)
      retval = PCDCommand.SetExpression ("0+" & DLG.CheckBox_1, MEAS_Y, 0)
      retval = PCDCommand.SetExpression ("0+0", MEAS_Z, 0)
      retval = PCDCommand.SetExpression ("0+0", MEAS_I, 0)
      retval = PCDCommand.SetExpression ("0+0", MEAS_J, 0)
      retval = PCDCommand.SetExpression ("0+1", MEAS_K, 0)
      retval = PCDCommand.PutText (Diameter, MEAS_DIAM, 0)
      retval = PCDCommand.PutText ("CDATA", ID, 0)
      retval = PCDCommand.SetToggleString (4, GEN_FEAT_TYPE, 0)


    SetExpression is what you want to be using, not PutText.
Children
No Data