Python

To indicate that you wish to use the Python Scripting Engine you need to put '#python' at the first line of the script.

The Python implementation of the K-3D API has the same functionallity as the JavaScript one.

#python

Application.UI.Message( "I will now open a new document.", "Hello, World!")
document = Application.NewDocument()
result = Application.UI.QueryMessage( "Do you wish to keep the document open?", "Question", ["Yes", "No"] )
if result == 2:
    Application.CloseDocument(document)

To find a complete reference to the whole language please visit http://www.python.org.

ApplicationClass

UIClass UI

Return the UI class.

ScriptEnginesClass ScriptEngine

Return the script engines class.

list Documents

Return a list of open documents.

string BasePath

Return the basepath of the running application.

string DialogTemplatesPath

Return the dialogtemplates path.

string LibPath

Return the lib path.

string ScriptsPath

Return the scripts path.

string ShadersPath

Return the shaders path.

string SharePath

Return the share path.

string TutorialsPath

Return the tutorials path.

string OptionsPath

Return the options path.

bool Close()

Close K-3D.

DocumentClass NewDocument()

Creates a new K-3D document.

DocumentClass OpenDocument( string file )

Opens a K-3D document.

bool CloseDocument( DocumentClass document )

Closes an open K-3D document.

CommandNodeClass CommandNode()

Return a commandnode.

UIClass

bool BrowserNavigate( string url )

Displays a URL in the user's preffered web browser.

bool Message( string message, string title )

Displays an informational message in a modal dialog box.

int QueryMessage( string message, string title, list buttons )

Prompts the user to choose one of selections in a modal dialog box.

bool ErrorMessage( string message, string title )

Displays an error in a modal dialog box.

string GetFilePath(string type, string prompt, bool promptoverwrite, string oldpath)

Prompts the user for a filepath, checking for old choices, and storing the current choice for reuse. Valid types:

  • renderfarm
  • script
  • document
  • geometry
  • log
  • font
  • renderframe

ScriptEnginesClass

bool PlayFile( string filename )

Execute the script file. Return true on success.

CommandNodeClass

bool Command( string command, string arguments )

Execute a command on the commandnode.

CommandNodeClass ChildName, same as : CommandNodeClass GetNode("ChildName")

Return node child (from the Command Node Inspector Tree).

value PropertyName, same as : value GetProperty("PropertyName")

Return node property (from the Command Node Inspector Tree).

PropertyName = value, same as : SetProperty("PropertyName", value)

Set node property.

list Children

Return node children as a string list (from the Command Node Inspector Tree).

list Properties

Return node properties as a string list (from the Command Node Inspector Tree).

DocumentClass

ApplicationClass GetApplication()

Return the application that owns document.

string GetPath()

Returns the filepath to the document.

bool Import( string file, string format )

Imports a geometry file into the document, using the given file format.

bool Export( string file, string format )

Exports the document to a geometry file, using the given file format.

bool Save( string file )

Save document to a given file.

bool StartChangeSet()

Records an original state that should be restored when undo.

bool FinishChangeSet( string string )

Undocumented.

bool Redraw()

Redraws all cameras.

ObjectClass CreateObject( string name )

Create a new K-3D object.

list Objects()

Return set of objects as list.

ObjectClass GetObject( string name )

Return named K-3D object.

bool DeleteObject( string name )

Delete named K-3D object.

CameraClass

DocumentClass GetDocument()

Return document that owns camera.

string GetSelectionMode()

Get the selection mode.

bool SetSelectionMode( string mode )

Set the selection mode.

bool ShowViewport()

Show the camera viewport.

bool HideViewport()

Hide the camera viewport.

bool Redraw()

Redraw viewport.

bool RenderPreview()

Render a preview.

bool RenderFrame( string outimage, bool viewimage )

Render a single frame.

bool RenderAnimation( string outimage, bool viewimages )

Render the animation.

ObjectClass

DocumentClass GetDocument()

Return document that own object.

string GetName()

Get object name.

bool SetName( string name )

Set object name.

tuple GetPosition()

Get object position. Tuple contain three (3) values.

bool SetPosition( tuple vector )

Set object position. Tuple contain three (3) values.

tuple GetOrientation()

Get object orientation. Tuple contain four (4) values. The first is the angle and the rest XYZ values.

bool SetOrientation( tuple vector )

Set object orientation. Tuple contain four (4) values. The first is the angle and the rest XYZ values.

tuple GetScale()

Get object scale. Tuple contain three (3) values.

bool SetScale( tuple vector )

Set object scale. Tuple contain three (3) values.

MeshClass GetMesh()

Return mesh.

CameraClass GetCamera()

Return camera.

bool EditObject()

Called to request that the object open its user interface.

MeshClass

list GetPoints()

Return points as a list.

list GetPaths()

Return paths as a list.

PointClass CreatePoint()

Creates a new point.

PathClass CreatePath()

Creates a new path.

PathClass

MeshClass GetMesh()

Return mesh that own path.

list GetPoints()

Retrn points in path as a list.

bool AddPoint( PointClass point )

Add point to collection.

bool RemovePoint( PointClass point )

Remove point from collection.

PointClass

MeshClass Mesh

Get mesh that own point.

bool Local = tuple vector

Set local XYZ. Tuple contain three (3) values.

tuple Local

Get local XYZ. Tuple contain three (3) values.

bool Animated = tuple vector

Set animated XYZ. Tuple contain three (3) values.

tuple Animated

Get animated XYZ. Tuple contain three (3) values.

bool World = tuple vector

Set world XYZ. Tuple contain three (3) values.

tuple World

Get world XYZ. Tuple contain three (3) values.

bool Camera = tuple vector

Set camera XYZ. Tuple contain three (3) values.

tuple Camera

Get camera XYZ. Tuple contain three (3) values.

bool Screen = tuple vector

Set screen XYZ. Tuple contain three (3) values.

tuple Screen

Get screen XYZ. Tuple contain three (3) values.

bool Normal = tuple vector

Set normal XYZ. Tuple contain three (3) values.

tuple Normal

Get normal XYZ. Tuple contain three (3) values.

bool Texture = tuple vector

Set texture XYZ. Tuple contain three (3) values.

tuple Texture

Get texture XYZ. Tuple contain three (3) values.

bool ImplicitTexture = tuple vector

Set implicit texture XYZ. Tuple contain three (3) values.

tuple ImplicitTexture

Get implicit texture XYZ. Tuple contain three (3) values.

<< Previous 
Table of Content
  Next >>