def bbppTransformation_CreateCorrespondanceIceTree(obj,group,map): oModel = PPG.Inspected(0).Parent3DObject oIceTree = XSI.ApplyOp("ICETree", obj, "siNode", "", "", 0) oCorrespondance = XSI.AddICECompoundNode("bbpp Correspondance Map", oIceTree) XSI.ConnectICENodes(str(oIceTree) + ".port1", str(oCorrespondance) + ".Execute") oGet1 = XSI.AddICENode("GetDataNode", oIceTree) oGet2 = XSI.AddICENode("GetDataNode", oIceTree) #sGroupName = replaceModelNameByThisModel(oModel,group.FullName) XSI.SetValue(str(oGet1) + ".reference", group.FullName) XSI.ConnectICENodes(str(oCorrespondance) + ".PointsGroup", str(oGet1) + ".outname") sMapName = replaceObjectNameBySelf(obj,map.FullName) XSI.SetValue(str(oGet2) + ".reference", sMapName + ".Colors") XSI.ConnectICENodes(str(oCorrespondance) + ".ColorMap", str(oGet2) + ".outname")
def applyColorizePointTree(model,obj,id): oIceTree = XSI.ApplyOp("ICETree", obj, "siNode", "", "", 0) oColorize = XSI.AddICECompoundNode("bbpp Colorize Point", oIceTree) XSI.ConnectICENodes(str(oIceTree) + ".port1", str(oColorize) + ".Execute") oGet1 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet1) + ".reference", model.FullName) XSI.ConnectICENodes(str(oColorize) + ".TransformationModel", str(oGet1) + ".outname") XSI.SetValue(str(oColorize) + ".PointID", id, "")
def MergeRigCloud(model, clouds, name): cloud = model.AddPrimitive("PointCloud", name) tree = XSI.ApplyOp("ICETree", cloud, "siNode", "", "", 2) idx = 1 for c in clouds: merge = XSI.AddICECompoundNode("MergeRigPointCloud", str(tree)) XSI.AddPortToICENode(str(tree) + ".port" + str(idx), "siNodePortDataInsertionLocationAfter") XSI.ConnectICENodes(str(tree) + ".port" + str(idx), str(merge) + ".execute") get = XSI.AddICENode("GetDataNode", str(tree)) XSI.SetValue(str(get) + ".reference", ReplaceModelNameByThisModel(c), "") XSI.ConnectICENodes(str(merge) + ".Cloud", str(get) + ".outname") idx += 1
def SetOneElementMap(crv, obj, name): weight_map = Utils.GetWeightMap(obj, name) tree = obj.ActivePrimitive.ICETrees.Find('SetOneElement') if not tree: tree = ICETree.CreateIceTree(obj, 'SetOneElement', 1) setter = XSI.AddICECompoundNode('SetOneElementMap', str(tree)) idx = tree.InputPorts.Count XSI.AddPortToICENode('{}.port{}'.format(tree, idx), 'siNodePortDataInsertionLocationAfter') XSI.ConnectICENodes('{}.port{}'.format(tree, idx), '{}.execute'.format(setter)) XSI.SetValue('{}.reference'.format(setter), 'this.cls.WeightMapCls.{}'.format(name), '') getter = XSI.AddICENode('GetDataNode', str(tree)) XSI.SetValue('{}.reference'.format(getter), ICETree.ReplaceModelNameByThisModel(crv), '') XSI.ConnectICENodes('{}.Guide_Curve'.format(setter), '{}.outname'.format(getter)) return weight_map
def bbppTransformation_BuildOutputMesh_OnClicked( ): oPPG = PPG.Inspected(0) oModel = oPPG.Parent3DObject oStartCloud = oModel.FindChild("StartCloud") oEndCloud = oModel.FindChild("EndCloud") oStartGrp = oModel.Groups("Start"); oEndGrp = oModel.Groups("End"); # does geometry exists? oStartGeomStatic = bbppTransformation_StartGeometryStaticExist(oPPG) oEndGeomStatic = bbppTransformation_EndGeometryStaticExist(oPPG) if not oStartGeomStatic or not oEndGeomStatic: XSI.LogMessage("bbppTransformation Geometry Does not exist ---> Can't build Output Mesh!", constants.siError) return if oPPG.AnimatedTransformation.Value: oStartGeomAnimated = bbppTransformation_StartGeometryAnimatedExist(oPPG) oEndGeomAnimated = bbppTransformation_EndGeometryAnimatedExist(oPPG) if not oStartGeomAnimated or not oEndGeomAnimated: XSI.LogMessage("bbppTransformation Geometry Does not exist ---> Can't build Output Mesh!", constants.siError) return # create start geometry point cloud if not oStartCloud: # create emission node oStartCloud = XSI.GetPrim("PointCloud", "StartCloud", oModel) oIceTree = XSI.ApplyOp("ICETree", oStartCloud, "siNode", "", "", 0) oEmit = XSI.AddICECompoundNode("bbpp Emit From Points", oIceTree) XSI.ConnectICENodes(str(oIceTree) + ".port1", str(oEmit) + ".add") oGet1 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet1) + ".reference", oStartGeomStatic.FullName) XSI.ConnectICENodes(str(oEmit) + ".Emiter", str(oGet1) + ".outname") XSI.SetValue(str(oEmit) + ".Color_red", 0.9) XSI.SetValue(str(oEmit) + ".Color_green", 0.4) XSI.SetValue(str(oEmit) + ".Color_blue", 0.1) # create blend node oBlend = XSI.AddICECompoundNode("bbpp Blend Cloud", oIceTree) XSI.AddPortToICENode(str(oIceTree) + ".port1", "siNodePortDataInsertionLocationAfter") XSI.ConnectICENodes(str(oIceTree) + ".port2", str(oBlend) + ".Execute") oGet2 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet2) + ".reference", str(oStartGrp)) XSI.ConnectICENodes(str(oBlend) + ".Start_Cloud", str(oGet2) + ".outname") oGet3 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet3) + ".reference", str(oEndGrp)) XSI.ConnectICENodes(str(oBlend) + ".End_Cloud", str(oGet3) + ".outname") oGet4 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet4) + ".reference", oEndGeomStatic.FullName) XSI.ConnectICENodes(str(oBlend) + ".Target_Geometry", str(oGet4) + ".value") # connect timer oTimer = XSI.AddICECompoundNode("bbpp Transformation Timer", oIceTree) XSI.ConnectICENodes(str(oBlend) + ".Blend", str(oTimer) + ".Blend") oGet5 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet5) + ".reference", oPPG.StartFrame.FullName) oGet6 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet6) + ".reference", oPPG.EndFrame.FullName) XSI.ConnectICENodes(str(oTimer) + ".Start_Frame", str(oGet5) + ".value") XSI.ConnectICENodes(str(oTimer) + ".End_Frame", str(oGet6) + ".value") # create end geometry point cloud if not oEndCloud: # create emission node oEndCloud = XSI.GetPrim("PointCloud", "EndCloud", oModel) oIceTree = XSI.ApplyOp("ICETree", oEndCloud, "siNode", "", "", 0) oEmit = XSI.AddICECompoundNode("bbpp Emit From Points", oIceTree) XSI.ConnectICENodes(str(oIceTree) + ".port1", str(oEmit) + ".add") oGet1 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet1) + ".reference", oEndGeomStatic.FullName) XSI.ConnectICENodes(str(oEmit) + ".Emiter", str(oGet1) + ".outname") XSI.SetValue(str(oEmit) + ".Color_red", 0.1) XSI.SetValue(str(oEmit) + ".Color_green", 0.9) XSI.SetValue(str(oEmit) + ".Color_blue", 0.4) # create blend node oBlend = XSI.AddICECompoundNode("bbpp Blend Cloud", oIceTree) XSI.AddPortToICENode(str(oIceTree) + ".port1", "siNodePortDataInsertionLocationAfter") XSI.ConnectICENodes(str(oIceTree) + ".port2", str(oBlend) + ".Execute") oGet2 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet2) + ".reference", str(oEndGrp)) XSI.ConnectICENodes(str(oBlend) + ".Start_Cloud", str(oGet2) + ".outname") oGet3 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet3) + ".reference", str(oStartGrp)) XSI.ConnectICENodes(str(oBlend) + ".End_Cloud", str(oGet3) + ".outname") oGet4 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet4) + ".reference", oStartGeomStatic.FullName) XSI.ConnectICENodes(str(oBlend) + ".Target_Geometry", str(oGet4) + ".value") # connect timer oTimer = XSI.AddICECompoundNode("bbpp Transformation Timer", oIceTree) XSI.ConnectICENodes(str(oBlend) + ".Blend", str(oTimer) + ".Blend") oGet5 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet5) + ".reference", oPPG.StartFrame.FullName) oGet6 = XSI.AddICENode("GetDataNode", oIceTree) XSI.SetValue(str(oGet6) + ".reference", oPPG.EndFrame.FullName) XSI.ConnectICENodes(str(oTimer) + ".Start_Frame", str(oGet5) + ".value") XSI.ConnectICENodes(str(oTimer) + ".End_Frame", str(oGet6) + ".value") XSI.SetValue(str(oTimer) + ".Revert", True) # create Blob Mesh # delete it if already exists bbppTransformation_BlobGeometryExist(oPPG) XSI.SelectObj(str(oStartCloud) + "," + str(oEndCloud)) XSI.Create_Polygonizer_Polymesh() oBlob = XSI.Selection(0) oBlob.Name = "OutputMesh" oModel.AddChild(oBlob) oBlobOp = oBlob.ActivePrimitive.ConstructionHistory.Find("Polygonizer") # create expression for in-between #-------------------------------------- # detail sStartFrame = oPPG.StartFrame.FullName sEndFrame = oPPG.EndFrame.FullName sTimelapse = sEndFrame+" - "+sStartFrame oExpr = "(1 - sin(cond(FC>"+sStartFrame+",cond(Fc<"+sEndFrame+",(Fc - "+sStartFrame+")/("+sTimelapse+"),1),0)*180)) *2 + 2" oBlobOp.Parameters("Detail").AddExpression(oExpr) # blur isofield oExpr = "sin(cond(FC>"+sStartFrame+",cond(Fc<"+sEndFrame+",(Fc - "+sStartFrame+")/("+sTimelapse+"),1),0)*180)/2" oBlobOp.Parameters("BlurIsofieldStrength").AddExpression(oExpr) # smooth mesh oExpr = "sin(cond(FC>"+sStartFrame+",cond(Fc<"+sEndFrame+",(Fc - "+sStartFrame+")/("+sTimelapse+"),1),0)*180)*4+2" oBlobOp.Parameters("SmoothMeshStrength").AddExpression(oExpr) # isolevel oBlobOp.Parameters("Isolevel").Value = 1
def GatherSkinDataOnSelf(skin): all_clusters = [] model = skin.Model elements = CollectSkeletonElements(model) for element in elements: # check cluster and weight map existence cluster_name = '{}_Cls'.format(element.ElementName.Value) cluster = skin.ActivePrimitive.Geometry.Clusters(cluster_name) if not cluster: cluster = Utils.CreateCompleteButNotAlwaysCluster( skin, constants.siVertexCluster, cluster_name) all_clusters.append(cluster) wm = Utils.GetWeightMap(skin, 'WeightMap', 1, 0, 1, cluster) # create build array and set data nodes tree = ICETree.CreateRigIceTree(skin, 'GatherDatas', 1) setter = XSI.AddICECompoundNode('Set Data', tree) XSI.SetValue( '{}.Reference'.format(setter), 'Self.__ElementWeights', ) build = XSI.AddICENode('BuildArrayNode', tree) XSI.ConnectICENodes('{}.value'.format(setter), '{}.array'.format(build)) XSI.ConnectICENodes('{}.port1'.format(tree), '{}.execute'.format(setter)) idx = 1 # connect each element map for cluster in all_clusters: getter = XSI.AddICECompoundNode('GetRigElementWeight', tree) if idx > 1: XSI.AddPortToICENode('{}.value{}'.format(build, idx - 1), 'siNodePortDataInsertionLocationAfter') XSI.SetValue('{}.reference'.format(getter), 'Self.cls.{}'.format(cluster.Name), "") XSI.ConnectICENodes('{}.value{}'.format(build, idx), '{}.Weight'.format(getter)) idx += 1 # check for weight maps Utils.GetWeightMap(skin, 'SmoothWeightMap', 1, 0, 1) Utils.GetWeightMap(skin, 'SearchMap', 1, 0, 1) Utils.GetWeightMap(skin, 'BulgeMap', 1, 0, 1) Utils.GetWeightMap(skin, 'StretchMap', 1, 0, 1) # get smooth weight map getter = XSI.AddICENode('GetDataNode', tree) XSI.SetValue('{}.reference'.format(getter), 'Self.cls.WeightMapCls.SmoothWeightMap.Weights', '') XSI.AddPortToICENode('{}.Value'.format(setter), 'siNodePortDataInsertionLocationAfter') XSI.SetValue('{}.Reference1'.format(setter), 'Self.__SmoothWeights', '') XSI.ConnectICENodes('{}.value1'.format(setter), '{}.value'.format(getter)) # get search map getter = XSI.AddICENode('GetDataNode', tree) XSI.SetValue('{}.reference'.format(getter), 'Self.cls.WeightMapCls.SearchMap.Weights', '') XSI.AddPortToICENode('{}.Value1'.format(setter), 'siNodePortDataInsertionLocationAfter') XSI.SetValue('{}.Reference2'.format(setter), 'Self.__PerPointSearch', '') XSI.ConnectICENodes('{}.value2'.format(setter), '{}.value'.format(getter)) # get stretch map getter = XSI.AddICENode('GetDataNode', tree) XSI.SetValue('{}.reference'.format(getter), 'Self.cls.WeightMapCls.StretchMap.Weights', '') XSI.AddPortToICENode('{}.Value2'.format(setter), 'siNodePortDataInsertionLocationAfter') XSI.SetValue('{}.Reference3'.format(setter), 'Self.__PerPointStretch', '') XSI.ConnectICENodes('{}.value3'.format(setter), '{}.value'.format(getter)) # get bulge map getter = XSI.AddICENode('GetDataNode', tree) XSI.SetValue('{}.reference'.format(getter), 'Self.cls.WeightMapCls.BulgeMap.Weights', '') XSI.AddPortToICENode('{}.Value3'.format(setter), 'siNodePortDataInsertionLocationAfter') XSI.SetValue('{}.Reference4'.format(setter), 'Self.__PerPointBulge', '') XSI.ConnectICENodes('{}.value4'.format(setter), '{}.value'.format(getter)) # show affected points affected = XSI.AddICECompoundNode('ShowRigAffectedPoints', tree) XSI.AddPortToICENode('{}.port1'.format(tree), 'siNodePortDataInsertionLocationAfter') XSI.ConnectICENodes('{}.port2'.format(tree), '{}.Execute'.format(affected))
def CorrectPush(obj, wmap, frame, exist): # check if tree exists prim = obj.ActivePrimitive tree = prim.ICETrees.Find("CorrectivePush") if not tree: tree = ICETree.CreateIceTree(obj, "CorrectivePush", 2) t = str(tree) set1 = XSI.AddICENode("SetOneDataNode", t) set1.Parameters("Reference").Value = "Self.PointPosition" ifnode = XSI.AddIceNode("IfNode", t) XSI.ConnectICENodes(t + ".port1", str(ifnode) + ".Result") XSI.ConnectICENodes(str(ifnode) + ".IfFalse", str(set1) + ".Value") get = XSI.AddICENode("GetDataNode", t) get.Parameters("Reference").Value = "Self.PointPosition" get1 = XSI.AddICENode("GetDataNode", t) get1.Parameters("Reference").Value = "Self.PointNormal" add = XSI.AddICENode("AddNode", t) XSI.ConnectICENodes(str(add) + ".Value1", str(get) + ".Value") add1 = XSI.AddIceNode("AddNode", t) mult = XSI.AddIceNode("MultiplyByScalarNode", t) mult1 = XSI.AddIceNode("MultiplyByScalarNode", t) XSI.ConnectICENodes(str(add) + ".Value2", str(mult) + ".Result") XSI.ConnectICENodes(str(mult) + ".Value", str(get1) + ".Value") XSI.ConnectICENodes(str(mult) + ".Factor", str(mult1) + ".Result") XSI.ConnectICENodes(str(mult1) + ".Value", str(add1) + ".Result") XSI.ConnectICENodes(str(set1) + ".Source", str(add) + ".Result") nodes = [get, get1, ifnode, add, add1, set1] compound = XSI.CreateICECompoundNode(",".join(nodes), None) XSI.EditICECompoundProperties(compound, "CorrectivePush", "", "", "", "", "", 1, 0, "", 4, 6732954) XSI.AddExposedParamToICECompoundNode(str(ifnode) + ".Condition", str(compound), None, "Mute") XSI.AddExposedParamToICECompoundNode(str(mult1) + ".Factor", str(compound), None, "Factor") if not exist: compound = tree.CompoundNodes("CorrectivePush") add = compound.Nodes.Filter("AddNode")(0) mult = XSI.AddIceNode("MultiplyByScalarNode", compound) addInputs = add.InputPorts checkPorts = -1 p = 0 for i in addInputs: if not i.IsConnected: checkPorts = p break p += 1 if not checkPorts == -1: XSI.ConnectIceNodes(str(add) + ".Value" + str(checkPorts + 1), str(mult) + ".Result") else: index = add.InputPorts.Count XSI.AddPortToICENode(str(add) + ".value" + str(index), constants.siNodePortDataInsertionLocationAfter) XSI.ConnectICENodes (str(add) + ".value" + str(index + 1), str(mult) + ".result") pushStr = "Self.cls.CorrectivePushCls."+wmap.Name+".Weights" getPushMap = XSI.AddIceNode("GetDataNode", str(tree)) getPushMap.Parameters("Reference").Value = pushStr inputs = compound.InputPorts count = 0 for i in inputs: if i.Name.find("Position")>-1: count += 1 XSI.AddExposedParamToICECompoundNode(str(mult) + ".value", str(compound), None, "Push") XSI.EditExposedParamInICECompoundNode(str(compound) + ".Push", "Push" + str(frame), "0", "0", None, None, 0, "") XSI.AddExposedParamToICECompoundNode(str(mult) + ".Factor", str(compound), None, "Frame" + str(frame)) XSI.EditExposedParamInICECompoundNode(str(compound) + ".Frame" + str(frame), "Frame" + str(frame), "0", "1", None, None, 0, "") XSI.ConnectICENodes(str(compound) + ".Push" + str(frame), str(getPushMap) + ".Value") XSI.InspectObj(compound, None, None, constants.siLock) XSI.SelectObj(wmap) XSI.PaintTool()
def CorrectShape(obj, cls, frame): prim = obj.ActivePrimitive tree = prim.ICETrees.Find("CorrectiveShape") exist = False basePos = None secondPos = None if tree: if cls.Properties("Frame"+str(frame)): exist = True toolkit = Dispatch("XSI.UIToolkit") buttonPressed = toolkit.MsgBox( "A corrective shape already exists for this frame\n Would you replace it??", constants.siMsgOkCancel, "Corrective Shape") if buttonPressed == constants.siMsgCancel: XSI.LogMessage("Store Secondary Shape cancelled by You, F**k TYou!!", constants.siInfo) return compound = tree.CompoundNodes("CorrectiveShape") if not exist: compound.InputPorts("Mute").Value = True XSI.DeactivateAbove(tree, True) basePoints = prim.Geometry.Points basePos = basePoints.PositionArray XSI.DeactivateAbove(tree, False) secondPoints = prim.Geometry.Points secondPos = secondPoints.PositionArray if not exist: compound.InputPorts("Mute").Value = False else: op = prim.ConstructionHistory.Find("AnimationMarker") XSI.DeactivateAbove(op, True) basePoints = prim.Geometry.Points basePos = basePoints.PositionArray XSI.DeactivateAbove(op, False) secondPoints = prim.Geometry.Points secondPos = secondPoints.PositionArray l = len(basePos[0]) delta = [0] * 3 * l for a in range(l): delta[a*3] = secondPos[0][a]-basePos[0][a] delta[a*3+1] = secondPos[1][a]-basePos[1][a] delta[a*3+2] = secondPos[2][a]-basePos[2][a] if not exist: shapeNode = Dispatch(cls.AddProperty("SimpleDeformShape", 0, "Frame"+str(frame))) shapeNode.Elements.Array = delta else: shapeNode = Dispatch(cls.Properties("Frame"+str(frame))) shapeNode.Elements.Array = delta if not tree: tree = ICETree.CreateIceTree(obj, "CorrectiveShape", 2) t = str(tree) set = XSI.AddICENode("SetOneDataNode", t) set.Parameters("Reference").Value = "Self.PointPosition" ifnode = XSI.AddIceNode("IfNode", t) XSI.ConnectICENodes(t + ".port1", str(ifnode) + ".Result") XSI.ConnectICENodes(str(ifnode) + ".IfFalse", str(set) + ".Value") get = XSI.AddICENode("GetDataNode", t) get.Parameters("Reference").Value = "Self.PointPosition" add = XSI.AddIceNode("AddNode", t) XSI.ConnectIceNodes(str(add) + ".Value1", str(get) + ".Value") XSI.ConnectIceNodes(str(set) + ".Source", str(add) + ".Result") compound = XSI.CreateICECompoundNode(str(get) + "," + str(set) + "," + str(add) + "," + str(ifnode), None) XSI.EditICECompoundProperties(str(compound), "CorrectiveShape", "", "", "", "", "", 1, 0, "", 4, 6732954) XSI.AddExposedParamToICECompoundNode(str(ifnode) + ".Condition", str(compound), None, "Mute") if not exist: compound = Dispatch(tree.Nodes("CorrectiveShape")) add = compound.Nodes.Filter("AddNode")(0) mult = XSI.AddIceNode("MultiplyByScalarNode", str(compound)) addInputs = add.InputPorts checkPorts = -1 p = 0 for i in addInputs: if not i.IsConnected: checkPorts = p break p += 1 if not checkPorts == -1: XSI.ConnectIceNodes(str(add) + ".Value" + str(checkPorts + 1), str(mult) + ".Result") else: index = add.InputPorts.Count XSI.AddPortToICENode(str(add) + ".Value" + str(index), constants.siNodePortDataInsertionLocationAfter) XSI.ConnectICENodes (str(add) + ".Value" + str(index + 1), str(mult) + ".Result") shapeStr = "Self.cls.CorrectiveShapeCls."+shapeNode.Name+".positions" getShape = XSI.AddIceNode("GetDataNode", str(tree)) getShape.Parameters("Reference").Value = shapeStr inputs = compound.InputPorts count = 0 for i in inputs: if i.Name.find("Position") > -1: count += 1 XSI.AddExposedParamToICECompoundNode(str(mult) + ".value", str(compound), None, "Position") XSI.EditExposedParamInICECompoundNode(str(compound) + ".Position", "Position" + str(frame), "0", "0", None, None, 0, "") XSI.AddExposedParamToICECompoundNode(str(mult) + ".Factor", str(compound), None, "Factor") XSI.EditExposedParamInICECompoundNode(str(compound) + ".Factor", "Frame" + str(frame), "0", "1", None, None, 0, "") XSI.ConnectICENodes(str(compound) + ".Position" + str(frame), str(getShape) + ".value") XSI.InspectObj(compound, None, None, constants.siLock) # delete all nodes between secondary shape modeling and animation markers for h in prim.ConstructionHistory: if h.FullName.find('marker') == -1: XSI.DeleteObj(h) if h.Name == 'Animation': break
def CorrectSmooth(obj, wmap, frame, exist): # check if tree exists prim = obj.ActivePrimitive tree = prim.ICETrees.Find( "CorrectiveSmooth" ) if not tree: above = prim.ICETrees.Find("CorrectivePush") if not above: above = prim.ICETrees.Find("CorrectiveShape") if above: XSI.DeactivateAbove(above, True) tree = ICETree.CreateIceTree(obj, "CorrectiveSmooth", 2) if above: XSI.DeactivateAbove(above, False) t = str(tree) set1 = XSI.AddICENode("SetOneDataNode", t) set1.Parameters("Reference").Value = "Self.PointPosition" ifnode = XSI.AddIceNode("IfNode", t) repeat = XSI.AddICENode("RepeatNode", t) XSI.ConnectICENodes(str(repeat) + ".port", str(set1) + ".value") repeat.InputPorts("iterations").Value = 10 XSI.ConnectICENodes(t + ".port1", str(ifnode) + ".Result") XSI.ConnectICENodes(str(ifnode) + ".IfFalse", str(set1) + ".Value") XSI.ConnectICENodes(str(ifnode) + ".IfFalse", str(repeat) + ".Execute") get = XSI.AddICENode("GetDataNode", t) get.Parameters("Reference").Value = "Self.PointPosition" get1 = XSI.AddICENode("GetDataNode", t) get1.Parameters("Reference").Value = "Self.PointNeighbors" get2 = XSI.AddICENode("GetDataNode", t) get2.Parameters("Reference").Value = "PointPosition" XSI.ConnectICENodes(str(get2) + ".Source", str(get1) + ".Value") average = XSI.AddICENode("GetArrayAverageNode", t) XSI.ConnectICENodes(str(average) + ".Array", str(get2) + ".Value") interp = XSI.AddIceNode("LinearInterpolateNode", t) XSI.ConnectICENodes(str(interp) + ".First", str(get) + ".Value") XSI.ConnectICENodes(str(interp) + ".Second", str(average) + ".Result") XSI.ConnectIceNodes(str(set1) + ".Source", str(interp) + ".Result") clamp = XSI.AddICENode("ClampNode", t) XSI.ConnectICENodes(str(interp) + ".Blend", str(clamp) + ".Result") scalarZero = XSI.AddICENode("ScalarNode", t) scalarZero.InputPorts("Value").Value = 0 scalarOne = XSI.AddICENode("ScalarNode", t) scalarOne.InputPorts("Value").Value = 1 add = XSI.AddICENode("AddNode", t) XSI.ConnectICENodes(str(clamp) + ".Limit1", str(scalarZero) + ".Result") XSI.ConnectICENodes(str(clamp) + ".Limit2", str(scalarOne) + ".Result") XSI.ConnectICENodes(str(clamp) + ".Value", str(add) + ".Result") nodes = [get, set1, get1, get2, average, interp, repeat, ifnode, clamp, add] compound = XSI.CreateICECompoundNode(",".join(nodes), None) XSI.EditICECompoundProperties(compound, "CorrectiveSmooth", "", "", "", "", "", 1, 0, "", 4, 6732954) XSI.AddExposedParamToICECompoundNode(str(ifnode) + ".Condition", str(compound), None, "Mute") XSI.AddExposedParamToICECompoundNode(str(repeat) + ".Iterations", str(compound), None, "Repeat") if not exist: compound = tree.CompoundNodes("CorrectiveSmooth") add = compound.Nodes.Filter("AddNode")(0) mult = XSI.AddIceNode("MultiplyByScalarNode", str(compound)) addInputs = add.InputPorts checkPorts = -1 i = 0 for p in addInputs: if not p.IsConnected: checkPorts = i break if checkPorts > -1: XSI.ConnectIceNodes(str(add) + ".Value" + str(checkPorts + 1), str(mult) + ".Result") else: index = add.InputPorts.Count XSI.AddPortToICENode(str(add) + ".Value" + str(index), constants.siNodePortDataInsertionLocationAfter) XSI.ConnectICENodes(str(add) + ".Value" + str(index + 1), str(mult) + ".Result") t = str(tree) smoothStr = "Self.cls.CorrectiveSmoothCls." + wmap.Name + ".Weights" get = XSI.AddIceNode("GetDataNode", t) get.Parameters("Reference").Value = smoothStr inputs = compound.InputPorts count = 0 for i in inputs: if not i.Name.find("Smooth") == -1: count += 1 XSI.AddExposedParamToICECompoundNode(str(mult) + ".value", str(compound), None, "Smooth") XSI.EditExposedParamInICECompoundNode(str(compound) + ".Smooth", "Smooth" + str(frame), "0", "0", None, None, 0, "") XSI.AddExposedParamToICECompoundNode(str(mult) + ".Factor", str(compound), None, "Factor") XSI.EditExposedParamInICECompoundNode(str(compound) + ".Factor", "Frame" + str(frame), "0", "1", None, None, 0, "") XSI.ConnectICENodes(str(compound) + ".Smooth" + str(frame), str(get) + ".Value") XSI.InspectObj(compound, None, None, constants.siLock) XSI.SelectObj(wmap) XSI.PaintTool()