Ruby

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

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

#ruby

app = ApplicationClass.new()

app.getUI().message("Welcome to Ruby!","Hello, World!")
document = app.newDocument()
result = app.getUI().queryMessage("Do you want to keep the document open?", "Question", ["Yes", "No"])
if result == 2
	app.closeDocument(document)
end

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

ApplicationClass

UIClass UI()

Return the UI class.

ScriptEnginesClass ScriptEngine()

Return the script engine class.

array Documents()

Return an array of open documents.

string BasePath()

Return the running applications base path.

string DialgoTemplatesPath()

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.

DocumentClass

ApplicationClass GetApplication()

Return the application that owns 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 )

Creates a new K-3D object.

ObjectCollectionClass Objects()

Returns the collection of K-3D objects within this document.

ObjectClass GetObject( string name )

Return named K-3D object.

bool DeleteObject( string name )

Deletes 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 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( array vector )

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

array GetOrientation()

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

bool SetOrientation( array vector )

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

array GetScale()

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

bool SetScale( array vector )

Set object scale. Array 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.

bool AddPoint( PointClass point )

Add point to path.

bool RemovePoint( PointClass point )

Remove point from path.

PointClass GetPoints()

Get points in path.

PointClass

MeshClass Mesh()

Get mesh that own point.

bool Local = array vector

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

array Local()

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

bool Animated = array vector

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

array Animated()

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

bool World = array vector

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

array World()

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

bool Camera = array vector

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

array Camera()

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

bool Screen = array vector

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

array Screen()

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

bool Normal = array vector

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

array Normal()

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

bool Texture = array vector

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

array Texture()

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

bool ImplicitTexture = array vector

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

array ImplicitTexture()

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

<< Previous 
Table of Content
  Next >>