The Python Script Engine allows the execution of python scripts. These scripts can be used to influence a GL Studio design in multiple ways, including creating objects, adding code and properties, and changing settings for the GL Studio design. The Python Script extension allows users to create scripts that automate common functions within GL Studio, including creating objects and code, and making changes to GL Studio editor and document settings. These scripts can also be mapped to custom toolbar buttons directly within the GL Studio interface, providing a quick and easy way to enact commonly used scripts.
A few examples to get you familiar with the scripting API.
import Editor
import EditorLog
import GLPolygon
import Group
import VertexArray
import Vertex
polygon.SetPolygonMode( polygon.POLY_MODE_FILLED )
polygon.SetName('poly')
currentDoc.InsertObject( polygon )
vertsList = [
]
yellowPolygon.SetPolygonMode( yellowPolygon.POLY_MODE_FILLED )
yellowPolygon.SetName('yellow')
currentDoc.InsertObject( yellowPolygon )
],
)
multiPolygon.SetPolygonMode( multiPolygon.POLY_MODE_FILL_AND_OUTLINE )
multiPolygon.SetShadingMode( multiPolygon.SHADING_GOURAUD )
multiPolygon.SetName('multi')
group.SetName('group')
currentDoc.InsertObject(group)
group.InsertObject(multiPolygon)
group.MoveObjectToGroup(yellowPolygon)
lookup = currentDoc.GetObjectByName('group')
for x in group:
def Process(prefix, x):
def PrintNames(group, prefix=''):
prefix = (prefix + '.' if prefix else '') + group.GetName()
for x in group:
Process(prefix, x)
if subgroup:
PrintNames(subgroup, prefix)
PrintNames( currentDoc.GetObjectList() )
Document GetCurrentDocument()
Gets the current document.
void PrintInfo(String str)
Output an info string to the editor log.
Definition: EditorLog.i:89
GLPolygon(VertexArray &vertices)
Creates a polygon with the specified vertices.
static GLPolygon * CastToGLPolygon(DisplayObject *obj)
Casts the Display Object as a GLPolygon NOTE: perform an isNULL check on the returned value to ensure...
Group()
Constructs an empty group.
static Group * CastToGroup(DisplayObject *obj)
Casts a DisplayObject to a Group (returns null on failure to cast)
VertexArray()
default ctor
Vertex()
Default constructor.
import Editor
import Vertex
import VertexArray
if docExists:
print( "Document exists." )
if not nullDoc:
print( 'Document does not exist' )
if not vertexArray:
print( 'The array is empty' )
vertexArray.Insert( vertex )
if vertexArray:
print( 'The array is not empty' )
soundList = docExists.GetSoundList()
soundList.AddSound( "someSound.mp3" )
soundItem = soundList.GetSoundItem( 0 )
if soundItem:
print( 'This SoundItem exists' )
soundList.RemoveSound( soundItem )
if not soundItem:
print( 'This SoundItem no longer exists' )
Document OpenDocument(String fileName)
Opens a new document and makes it the current document.
See the GL Studio Users Manual as well as the Cpp Tutorial for more information on Custom Script Buttons and examples.