Softimage Curve CopyIcon
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | from win32com.client import constants as c from win32com.client import Dispatch as d xsi = Application log = xsi.LogMessage collSel = xsi.Selection DEBUG = 0 def copyIcon(): if collSel.Count < 1: log("No target curves selected.",4) return False collPreSelection = d("XSI.Collection") collPreSelection.SetAsText(collSel.GetAsText()) oPick = xsi.PickElement(c.siCurveFilter,"Pick Source Curve","Pick Source Curve") if oPick(0) == 0: log("Copy Icon cancelled",4) return False oSrcCurve = oPick(2) oSrcCurveGeo = oSrcCurve.ActivePrimitive.Geometry oSrcCrvList = oSrcCurveGeo.Curves intSrcCrvCount = oSrcCrvList.Count for eachCurve in collPreSelection: xsi.FreezeModeling(eachCurve) oCrvGeo = eachCurve.ActivePrimitive.Geometry oCrvList = oCrvGeo.Curves for i in range(intSrcCrvCount): aSrcCrvDef = oSrcCrvList(i).Get2(c.siSINurbs) if i > oCrvList.Count - 1: oCrvGeo.AddCurve(aSrcCrvDef[0],None,aSrcCrvDef[2],aSrcCrvDef[3],c.siNonUniformParameterization,c.siSINurbs) else: oCrvList(i).Set(aSrcCrvDef[0],None,aSrcCrvDef[2],aSrcCrvDef[3],c.siNonUniformParameterization,c.siSINurbs) copyIcon() |
PassManger 3.0 Preview
A walk through of the new version of ET PassManager. New features include:
- GUI to allow selected of passes and settings to export
- 1 file export / import
- Scene Renderer Settings
- Pass Environment Shaders on passes
- Local Renderer Settings (local Mental Ray setting on passes)
- Complete Rewrite to optimize code (Not compatible with earlier versions, Sorry.)
If you're intersted in testing the new version please send me an email which you can find at ethivierge.com
Chain UpVector Positioning
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | from win32com.client import constants as c from win32com.client import Dispatch as d xsi = Application log = xsi.LogMessage oSceneRoot = xsi.ActiveProject2.ActiveScene.Root collSel = xsi.Selection # Create rotation vectors vecHip = XSIMath.CreateVector3() vecKnee = XSIMath.CreateVector3() vecAnkle = XSIMath.CreateVector3() vec1 = XSIMath.CreateVector3() vec2 = XSIMath.CreateVector3() vecCross = XSIMath.CreateVector3() vecUpVectorPos = XSIMath.CreateVector3() collSel(0).Kinematics.Global.Transform.GetTranslation(vecHip) collSel(1).Kinematics.Global.Transform.GetTranslation(vecKnee) collSel(2).Kinematics.Global.Transform.GetTranslation(vecAnkle) vec1.Sub(vecHip, vecAnkle) vec2.Sub(vecHip, vecKnee) vecXUpVector = XSIMath.CreateVector3() vecYUpVector = XSIMath.CreateVector3() vecZUpVector = XSIMath.CreateVector3() vecUpVectorPos.LinearlyInterpolate( vecHip, vecAnkle, 0.5 ) vecXUpVector.Cross(vec2,vec1) vecYUpVector.Sub(vecUpVectorPos,vecHip) vecZUpVector.Sub(vecKnee,vecUpVectorPos) vecPosOffset = XSIMath.CreateVector3() vecPosOffset.Sub(vecKnee,vecUpVectorPos) vecPosOffset.Set(vecPosOffset.X * 2,vecPosOffset.Y,vecPosOffset.Z * 2) vecUpVectorPos.AddInPlace(vecPosOffset) vecXUpVector.NormalizeInPlace() vecYUpVector.NormalizeInPlace() vecZUpVector.NormalizeInPlace() xformUpVector = XSIMath.CreateTransform() xformUpVector.SetRotationFromXYZAxes(vecXUpVector,vecYUpVector,vecZUpVector) xformUpVector.SetTranslation(vecUpVectorPos) collSel(3).Kinematics.Global.PutTransform2("",xformUpVector) |
Write Clean XML
I've been working with XML for a while now and haven't found a solution to clean up the XML code in the written file until now. I searched for any articles about how to clean up the XML and finally fond some sample script here: http://snipplr.com/view/25657/indent-xml-using-elementtree/. I modified it a bit for my needs in XSI and it works great!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | from xml.etree import ElementTree as ET from win32com.client import constants as c from win32com.client import Dispatch as d xsi = Application log = xsi.LogMessage collSel = xsi.Selection def indent(elem, level=0): i = "\n" + level*" " if len(elem): if not elem.text or not elem.text.strip(): elem.text = i + " " if not elem.tail or not elem.tail.strip(): elem.tail = i for elem in elem: indent(elem, level+1) if not elem.tail or not elem.tail.strip(): elem.tail = i else: if level and (not elem.tail or not elem.tail.strip()): elem.tail = i def cleanxml(xml): elem = ET.fromstring(xml) indent(elem) strIndented = ET.tostring(elem) return strIndented def cleanWriteXML(strFilePath): fOpen = open(strFilePath,"r") fRead = fOpen.read() fWrite = open(strFilePath,"w") strPrettyXML = cleanxml(fRead) fWrite.write(strPrettyXML) fWrite.close() cleanWriteXML("C:\\Path\\To\\File.xml") |
Pickup v2.0
I just re-wrote the ET_Pickup plug-in / addon as it wasn't working with reference models. Strange how I find out years later that it doesn't work!
Either way, this should work since I changed it from keying the Active Parameter on constraints to the BlendWeight parameter.
Download (Right Click > Save Target As)
Python – Get Python and pywin32 version
This code gets the working Python and pywin32 version numbers.
import sys import os import distutils import distutils.sysconfig site_packages = distutils.sysconfig.get_python_lib(plat_specific=1) build_no = open(os.path.join(site_packages, "pywin32.version.txt")).read().strip() print "Python version: " + sys.version print "PyWin32 version: " + build_no
Get Selected ICE Compound function
Needed to get the selected ICE Compounds via scripting today and finally got a working function that returns a dictionary { Name:FullName }. See below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | from win32com.client import constants as c xsi = Application log = xsi.LogMessage def getSelectedICECompounds(): collViews = xsi.Desktop.ActiveLayout.Views oICETreeView = collViews("ICE Tree") if oICETreeView: strNodes = oICETreeView.GetAttributeValue("selection") if not strNodes: log("No nodes selected.") return lSelectedNodes = strNodes.split(",") dICECompounds = {} for eachNode in lSelectedNodes: oNode = xsi.Dictionary.GetObject(eachNode) if oNode.IsClassOf(c.siICECompoundNodeID): lFullNameSplit = oNode.FullName.rsplit(".") dICECompounds[lFullNameSplit[len(lFullNameSplit) - 1]] = oNode.FullName return dICECompounds else: log("ICE Tree view not found!",2) |
AnimStore v1.1
Updated the plug-in which I believe fixes the issue where now you don't have to edit the __init__.py file. Please post any issues.
I also fixed the bit where the warning message about not having the pose cam actually displays at the bottom of the screen.
I also stored the original selection and re-select it after importing the camera.