Cookbook

This cookbook has the purpose to provide a great collection of useful examples and explanations.
Feel free to share your recipes with the community on PluginCafe developer forum.

Recipes

See also

Play the animation and cache stuff: Document Animation

See also

Overview of all predefined Noise Types: Noise Types

Code snippets

The following code-snippets will help you to get some workarounds for everyday stuff. This collection is still in progress.

How to get the active editor/object camera

How to get the current active camera

def GetCamera(doc):
    """
    Returns the active camera.
    Will never be None.
    """
    bd = doc.GetRenderBaseDraw()
    cp = bd.GetSceneCamera(doc)
    if cp is None:
        cp = bd.GetEditorCamera()

    return cp

Limit the magnitude of a Vector

Limit the magnitude of a Vector

def LimitVector(v, max):
    """
    This function limit the
    magnitude of a Vector
    """

    if v.GetLength()>max:
        v.Normalize()
        v *= max