Python Script Engine  8.2
GL Studio Editor Python Script API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Truth Value Checking

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

Objects from this API are considered false when:

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' )
Document OpenDocument(String fileName)
Opens a new document and makes it the current document.
Document NewDocument(String filename="")
Creates a new document and makes it the current document.
VertexArray()
default ctor
Vertex()
Default constructor.