Here’s a script that goes through the SimulationEnvironments of a scene and find the 3d objects in each SimulationEnvironment. This snippet builds a dictionary of 3d objects, indexed by simulation environment.
from siutils import si
si = si() # win32com.client.Dispatch('XSI.Application')
from siutils import log # LogMessage
from siutils import disp # win32com.client.Dispatch
from siutils import C # win32com.client.constants
from xml.etree import ElementTree as ET
# Use a dictionary to store the 3d objects keyed by Environmen
dict = {}
for e in si.ActiveProject2.ActiveScene.SimulationEnvironments:
stack = XSIUtils.DataRepository.GetConnectionStackInfo( e.SimulationTimeControl )
xmlRoot = ET.fromstring( stack )
for xmlConnections in xmlRoot.findall('connection'):
o = xmlConnections.find( 'object' )
dict[ si.Dictionary.GetObject( o.text ).Parent3DObject.FullName ] = e.FullName
log( "3DObjects and their SimulationEnvironments" )
for key, value in dict.items():
log( "\t%s, %s" % (key,value) )
log( "" )
log( "SimulationEnvironments and 3DObjects" )
dictvals = set( dict.values() )
for env in dictvals:
log( "\t%s" % env )
list = [k for k, v in dict.iteritems() if v == env]
for o in list:
log( "\t\t%s" % o )
Here’s some sample output from the script:
# INFO : 3DObjects and their SimulationEnvironments # INFO : pointcloud1, Environments.Environment # INFO : Point_cloud_chaser.pointcloud2, Environments.Environment1 # INFO : grid, Environments.Environment # INFO : Point_cloud_chaser.pointcloud1, Environments.Environment1 # INFO : pointcloud, Environments.Environment # INFO : Point_cloud_chaser.pointcloud, Environments.Environment1 # INFO : # INFO : SimulationEnvironments and 3DObjects # INFO : Environments.Environment1 # INFO : Point_cloud_chaser.pointcloud2 # INFO : Point_cloud_chaser.pointcloud1 # INFO : Point_cloud_chaser.pointcloud # INFO : Environments.Environment # INFO : pointcloud1 # INFO : grid # INFO : pointcloud