Python Script Engine  8.0
GL Studio Editor Python Script API
TruthValueChecking.py

Example on how to do Truth Value Checking

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