DieselExpression if statement in field

Hi, I wrote the following DieselExpression: $(if, $(<, x 150), 150 , 200)
This is in a field inside an MText. It should evaluate x and if x is smaller than 150, the MText value should be 150. If x is larger that 150, the MText value should be 200. The expression seems works if I manually substitute a value for x.

My question is, how do I feed a value into the expression, for instance to grab the contents of another MText and substitute it for x?

I looked at Getvar, but it doesn't seem to be what I'm looking for. If it is not possible, is there another way to use an if statement in a field?

Thanks in advance.

Comments

  • Its_Alive
    edited September 2022
    how about get set env?
    (setenv "MYENV" "200")
    (setenv "MYENV" "100")
    $(if, $(<, $(getenv, "MYENV") , 150), 150 , 200)

    haven't tried, but maybe you can do a nested field
  • Wouldn't an MTEXT field require a string value?
  • ALANH
    edited September 2022
    Did a google and it looked like could combine diesel with <Acprop etc and get value, but could not find a specific example just found all most there or working but no example.

    Google'd IF Field Autocad etc.
  • $(if, $(<, %<\AcObjProp Object(%<\_ObjId 3295699057840>%).TextString>% , 150), 150 , 200)

    works in AutoCAD, but only once, because the inner expression is evaluated, my guess is, it might be possible to create a nested field programmatically, maybe in .net. I don't see a way via the interface