Using available AnySwitch variables

Hello,

Is there a functional way to use the (already available) switches in my own own code?

What I want to do is to store the Jii vector if it was actually the Jii around the CoM or an empty vector otherwise. However, when I use the code below the compiler does not seem to accept the AnySwitchVar for an #if statement, even tough in my own classes I’ve done similar things using string variables
(e.g. “#if Var == “On””)

Code:
#if JaboutCoMOnOff == On
AnyVec3 Jii = .AMSSeg.Jii;
#else
AnyVec3 Jii = {0,0,0};
#endif

Error message:
ERROR(SCR.SCN6) : <Myfile.any>: ‘JaboutCoMOnOff’: Unexpected character.
Kind regards,

Bart Koning

Dear Bart Koning,

In AnyScript, you can’t use any kind of variables with #if statements.

Generally speaking, #if statement can be used with some predefined constants by #define statements.

For your interest, attached please find two anyscript files which replicates what you want to do about Jii values.

One file uses #if and #define statements and the other one uses ‘iffun’ function which can be used with some user-defined variables.

I hope this files may be helpful to you.

Best regards,
Moonki