| Python Script Engine 8.3 GL Studio Editor Python Script API

Truth Value Checking

Here is an example of how truth value checking works in this API.

Objects from this API are considered false when:

- The object is null
- The object is an empty array
- Special cases such as SoundItem and TexturePaletteEntry. These are considered null once they are removed from a SoundList or TexturePalette, respectively

Python Docs on Truth Value Checking

import Editor
import Vertex
import VertexArray
# Opening two documents, one new document, and one that doesn't exist
docExists = Editor.NewDocument()
nullDoc = Editor.OpenDocument( "nonExistentDoc.gls" )
# Will be True because the document object exists
if docExists:
print( "Document exists." )
# Will be considered False since the object is null
if not nullDoc:
print( 'Document does not exist' )
# Creating an empty VertexArray
vertexArray = VertexArray.VertexArray()
# Will be considered False because the array object is empty
if not vertexArray:
print( 'The array is empty' )
# Adding a vertex to the array
vertex = Vertex.Vertex( 0, 0, 0 )
vertexArray.Insert( vertex )
# Will now be considered True because the array is not empty
if vertexArray:
print( 'The array is not empty' )
# Retrieving the document's sound list and adding a sound to it
soundList = docExists.GetSoundList()
soundList.AddSound( "someSound.mp3" )
soundItem = soundList.GetSoundItem( 0 )
# The SoundItem exists as long as it's in the SoundList
if soundItem:
print( 'This SoundItem exists' )
# Once the SoundItem is removed, it is considered null, and therefore false
soundList.RemoveSound( soundItem )
if not soundItem:
print( 'This SoundItem no longer exists' )
Editor::OpenDocument
Document OpenDocument(String fileName)
Opens a new document and makes it the current document.
Editor::NewDocument
Document NewDocument(String filename="")
Creates a new document and makes it the current document.
VertexArray::VertexArray
VertexArray()
default ctor
Vertex::Vertex
Vertex()
Default constructor.