Processing the Values

This part translates the entered values into variables that can be used to create the emitter and adjust its physical properties. To trigger this process, the script has to check first whether the entered values have been accepted or not. That is necessary, because each window shows an “OK” and a “Cancel” button. By confirming with “OK”, you tell RealFlow that the values have been accepted and should be used to feed the script. This query is done with the show() function:

int show()

 

The statement returns an integer specifying the button you have pressed. 1 stands for “OK” and 2 indicates that the operation has been aborted with “Cancel” or the ESC key. The query itself is packed into an if-condition to start with the translation of the values. Similar to the “get” instruction with parameters, where you can read out values from nodes, GUI functions also offer the get statement:

getFieldValue(string)

  

Here you do not have to think about data types any more, because they have already been determined with the initialization of the GUI. The string stands for the appropriate field’s unique name. So the code for processing the entered values is written this way:

if (window.show() == GUI_DIALOG_ACCEPTED):
    emitter_type  = window.getFieldValue("Emitter Type")
    particle_type = window.getFieldValue("Particle Type")
    resolution    = window.getFieldValue("Resolution")
    density       = window.getFieldValue("Density")
    intpres       = window.getFieldValue("Int Pressure")
    extpres       = window.getFieldValue("Ext Pressure")
    viscosity     = window.getFieldValue("Viscosity")
    tension       = window.getFieldValue("Surface Tension")
    name          = window.getFieldValue("Name")
 
else:
    scene.message("The emitter was not created.")

 

Please keep in mind that the names in brackets have to match the names from the previous field definition exactly, but without the default value:

window.addFloatField("Density", 1000.0) -> window.getFieldValue("Density")

 

If you want to share the values over different functions or even scripts, then it is necessary to define them as global variables.

Now it is already possible to execute the script and check the GUI for plausibility. As you can see from the image, RealFlow takes the field definitions and directly lists them in the order you have specified. That is new, because in previous program versions the fields were added alphabetically and you had to add a suffix, for example an enumeration to create a certain order. In case you want to use older scripts you can remove the prefix now.

 

The GUI so far with the defined fields.