Python Script Engine  8.2
GL Studio Editor Python Script API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
TruthValueChecking.py

Example on how to do Truth Value Checking.

Example on how to do Truth Value Checking

1import Editor
2import Vertex
3import VertexArray
4
5# Opening two documents, one new document, and one that doesn't exist
6docExists = Editor.NewDocument()
7nullDoc = Editor.OpenDocument( "nonExistentDoc.gls" )
8
9# Will be True because the document object exists
10if docExists:
11 print( "Document exists." )
12
13# Will be considered False since the object is null
14if not nullDoc:
15 print( 'Document does not exist' )
16
17# Creating an empty VertexArray
18vertexArray = VertexArray.VertexArray()
19
20# Will be considered False because the array object is empty
21if not vertexArray:
22 print( 'The array is empty' )
23
24# Adding a vertex to the array
25vertex = Vertex.Vertex( 0, 0, 0 )
26vertexArray.Insert( vertex )
27
28# Will now be considered True because the array is not empty
29if vertexArray:
30 print( 'The array is not empty' )
31
32# Retrieving the document's sound list and adding a sound to it
33soundList = docExists.GetSoundList()
34soundList.AddSound( "someSound.mp3" )
35soundItem = soundList.GetSoundItem( 0 )
36
37# The SoundItem exists as long as it's in the SoundList
38if soundItem:
39 print( 'This SoundItem exists' )
40
41# Once the SoundItem is removed, it is considered null, and therefore false
42soundList.RemoveSound( soundItem )
43if not soundItem:
44 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.