Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
themeEclipse
languagepython
linenumberstrue
window.addIntField(string, int)
window.addFloatField(string, float)
window.addVectorField(string, float, float, float)
window.addStringField(string, string)
window.addBoolField(string, boolean)
window.addListField(string, string, int)

 

 

The common thing with all fields is the first string statement within the brackets. Here you can enter an arbitrary name that will be displayed in the GUI window. Most field definitions expect two arguments, but  addVectorField requires four, the addListField three entries. The meaning of the vector field’s arguments should be pretty clear now, because a vector always consists of three floating numbers. With list fields it is a little bit different. The second string determines a predefined list variable with appropriate entries:

...

 

Code Block
themeEclipse
languagepython
objects = [Sphere","Cube","Vase","Torus","Rocket"]

...

A correct construction would be:  

Code Block
themeEclipse
languagepython
linenumberstrue
window.addFloatField("Particle Friction", 0.001)
window.addFloatField("Object Friction", 0.005) 

...

A good example for the definition of a GUI window is a script-based creation of an emitter. You can write the following code to a batch script window:

...

Code Block
themeEclipse
languagepython
linenumberstrue
window = GUIFormDialog.new()
 
emitter_types  = ["Circle","Square","Sphere","Linear","Cylinder"]
particle_types = ["Liquid","Dumb","Elastics"]

window.addListField("Emitter Type", emitter_types, 0)
window.addListField("Particle Type", particle_types, 0)
window.addFloatField("Resolution", 1.0)
window.addFloatField("Density", 1000.0)
window.addFloatField("Int Pressure", 1.0)
window.addFloatField("Ext Pressure", 1.0)
window.addFloatField("Viscosity", 3.0)
window.addFloatField("Surface Tension", 1.0)
window.addStringField("Name", "Emitter")

...

 

The fields represent the most important physical parameters of an emitter. If you have often-used settings, you can change the defaults to your needs, e.g. higher resolution:

Code Block
themeEclipse
languagepython
window.addFloatField("Resolution", 5.0)

...

Info
This is the first part of GUI creation, and so far the script does not work, because some important elements and definitions are still missing.