Special Projects Introduction To Python

There's growing interest from those who are technically minded to learn Python and I think it has a great future in XSI. In the interest of helping others considering the switch, here are a set of examples.

Start with the Basics of a Simple Loop

   
a = Application
for i in range(1,10):
		a.logmessage(i) 

Next Log an Array

b = [1,34,5,546,43,3]

a = Application

for i in b:
		a.logmessage(i)

Next a simple file UI


a = Application
from win32com.client import constants




fb = XSIUIToolkit.FileBrowser
fb.Filter = "Maya Ascii (*.ma)|*.ma||"
fb.ShowOpen()
a.logmessage(fb.FilePathName);
a.logmessage(fb.FileName);
a.logmessage(fb.FileExtension);
a.logmessage(fb.FilePath);



def getUI():

	sliders = a.ActiveSceneRoot.AddProperty( "CustomProperty", 0, "MA XSI Import" )
	File = sliders.AddParameter3("File", constants.siString, "c:\\",0,1)
	
	layout = sliders.PPGLayout
	layout.Clear()
	
	layout.AddGroup("Path")
	item1 = layout.AddItem ("File", "File", constants.siControlFilePath)
	layout.EndGroup()

	try:
		a.inspectobj( sliders, "", "Maxsi", constants.siModal )
	except:
		a.logmessage("hit cancel")
		a.deleteobj(sliders)
		return
		
		
	fileValue = File.Value
	a.deleteobj(sliders)
	
	return fileValue
	
'''
ui = getUI()

if ui:
	a.logmessage(ui)
	
'''

This page was last modified 13:32, 4 Jul 2006.
This page has been accessed 2311 times.