Command Evaluation¶
Context |
Evaluation context. |
run |
Randomly run weighted commands from a set. |
-
class
revl.
Context
(**kwargs)[source]¶ Evaluation context.
Each command function needs to define this context as first parameter.
-
dg
¶ maya.OpenMaya.MDGModifier – DG modifier.
-
dag
¶ maya.OpenMaya.MDagModifier – DAG modifier.
-
transforms
¶ list of maya.OpenMaya.MObject – Transform nodes. Provides data for the
pickTransform()
function.
-
-
revl.
run
(commands, count, seed=None, context=None)[source]¶ Randomly run weighted commands from a set.
Each command comes with a weight which determines the probabilities for that command to be run.
Use
validate()
to check if the input command set is well-formed.Parameters: - commands (list of revl.Command or compatible tuple) – Set of weighted commands.
- count (int) – Total number of commands to be run. Setting a count greater than the number of weighted commands doesn’t guarantee that each command will be run once. Some might be run multiple times instead.
- seed (object) – Hashable object to define the starting seed of the pseudo-random
number generations. If
None
, the current system time is used. Running multiple times a same set of commands with a same fixed seed that is notNone
produces identitcal results. - context (revl.Context) – Context to use. If
None
, a new one is created.
Returns: The context after evaluating the commands.
Return type: Examples
>>> import revl >>> commands = [ ... (2.0, revl.createTransform,), ... (1.0, revl.createPrimitive, (), {'parent': True}) ... ] >>> revl.run(commands, 100, seed=1.23)