Finding the camera used by a texture projection Part II

Part I

Another way to get the cameras for the camera projections on the selected object. This time with no loops (well, except for the list comprehension on line 22).

from siutils import si
if Application.Version().split('.')[0]>= "11":
	    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

# Get all CameraTxt operators
ops = si.FindObjects2( C.siOperatorID ).Filter( "CameraTxt" )

# Filter function to get the CameraTxt ops under the selected object
def f(x):
	o = si.Selection(0)
	return o.IsEqualTo( x.Parent3DObject )

# Get list of cameras
cams = [ x.InputPorts(2).Target2.Parent3DObject for x in filter( f, ops ) ]

if len(cams) > 0:
	print 'Projection cameras for %s:' % si.Selection(0)
	for c in cams:
		print '   %s' % c.Name

This script is based on the observation that you can get the camera from an input port on the CameraTxt operator.