3.6.4. Accessing a Scheme Variable in a UDF

After a new variable is defined on the Scheme side (using a text command), you will need to bring it over to the solver side to be able to use it in your UDF. ‘ RP’ macros are used to access Scheme variables in UDFs, and are listed below.

RP_Variable_Exists_P("variable-name")

Returns true if the variable exists

RP_Get_Real("variable-name")

Returns the double value of variable-name

RP_Get_Integer("variable-name")

Returns the integer value of variable-name

RP_Get_String("variable-name")

Returns the char* value of variable-name

RP_Get_Boolean("variable-name")

Returns the Boolean value of variable-name

Get_Input_Parameter("variable-name")

Returns the input parameter value of variable-name

For example, to access the user-defined Scheme variable pres_av/thread-id in your UDF C function, you will use RP_Get_Integer. You can then assign the variable returned to a local variable you have declared in your UDF (for example, surface_thread_id) as demonstrated below:

  surface_thread_id = RP_Get_Integer("pres_av/thread-id"); 

Release 18.2 - © ANSYS, Inc. All rights reserved.