| Python Script Engine 8.3 GL Studio Editor Python Script API

TruthValueChecking.py

Example on how to do Truth Value Checking.

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
6docExists = Editor.NewDocument()
7nullDoc = 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
18vertexArray = 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
25vertex = Vertex.Vertex( 0, 0, 0 )
26vertexArray.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
33soundList = docExists.GetSoundList()
34soundList.AddSound( "someSound.mp3" )
35soundItem = 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
42soundList.RemoveSound( soundItem )
43 if not soundItem:
44 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.