import win32com from win32com.client import constants as c xsi = win32com.client.Dispatch( 'XSI.Application' ).application log = xsi.LogMessage oSelected = Application.Selection if (oSelected(0) > 0): log (oSelected) oGeometry = oSelected(0).ActivePrimitive.Geometry oClusters = oGeometry.Clusters log ("The number of clusters in this object is " + str(oClusters.count) ) if (oClusters.count == 0): log("creating two clusters") xsi.CreateProjection("cube", "siTxtCubic", "siTxtDefaultCubic", "", "UV1", "", "", "") xsi.GenerateUniqueUVs("", "UV2", "", "", "", "", "", "", "") xsi.SetValue(str(oSelected(0)) + ".polymsh.cls.Texture_Coordinates_AUTO.UV2.PolyPackUV.grouptol", 30, "") xsi.FreezeObj("", "", "") #iSel is the current array for iSel in range( oClusters.count): if (oClusters(iSel) == 0): log("no cluster") elif (oClusters(iSel) > 0): log ("###########CLUSTERS#########") log ( oClusters(iSel).name ) log ( oClusters(iSel).name + " is a " + oClusters(iSel).type ) elif (oClusters(iSel) == 0 and oClusters(iSel).type == "sample"): log ( "No UVs" ) break elif (oClusters(iSel) == 1 and oClusters(iSel).type == "sample"): log ( "Only one UV channel" + oClusters(0).name) log ( "................Unwraping and creating UV2" ) break elif (oClusters(iSel).type == "sample" and oClusters(iSel).name == "UV2"): log("Rendering AO and exporting to Worldforge in OGRE") break # elif (oClusters(iSel).name != "UV2"): # log("Need to change Name to UV2") # break else: log("Select a mesh")