コード例 #1
0
def attachPolyMesh(name, identifier, jobInfo, isConstant=False):
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._attach.attachPolyMesh")
    if cmds.objExists(name):
        if cmds.objectType(name) != "mesh":
            print("Only mesh can be attached too!")
            cmds.ExocortexAlembic_profileEnd(
                f="Python.ExocortexAlembic._attach.attachPolyMesh")
            return

        polyObj = cmds.connectionInfo(
            name + ".inMesh",
            sfd=True).split('.')[0]  # cmds.plugNode doesn't exist!
        if polyObj and cmds.objectType(
                polyObj
        ) == "ExocortexAlembicPolyMeshDeform":  # it's already attached to a deform, simply change the file reference
            attachTimeAndFile(polyObj, jobInfo, isConstant)
            return

        # create deformer, and attach time and file
        newDform = cmds.deformer(name,
                                 type="ExocortexAlembicPolyMeshDeform")[0]
        cmds.setAttr(newDform + ".identifier", identifier, type="string")
        attachTimeAndFile(newDform, jobInfo, isConstant)

        if jobInfo.useFaceSets:
            cmds.ExocortexAlembic_createFaceSets(
                f=cmds.getAttr(jobInfo.filenode + ".outFileName"),
                i=identifier,
                o=name)

    cmds.ExocortexAlembic_profileEnd(
        f="Python.ExocortexAlembic._attach.attachPolyMesh")
    pass
コード例 #2
0
ファイル: _import.py プロジェクト: Rotomator/PipeL
def importPolyMesh(name, identifier, jobInfo, parentXform=None, isConstant=False, useDynTopo=False):
	cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._import.importPolyMesh")

	try:
		reader = ""
		shape  = fnt.alembicCreateNode(name, "mesh", parentXform)
		cmds.sets(shape, e=True, forceElement="initialShadingGroup")

		topoReader = cmds.createNode("ExocortexAlembicPolyMesh")
		cmds.connectAttr(topoReader+".outMesh", shape+".inMesh")
		cmds.connectAttr(jobInfo.filenode+".outFileName", topoReader+".fileName")
		cmds.setAttr(topoReader+".identifier", identifier, type="string")
		cmds.setAttr(topoReader+".normals", jobInfo.useNormals)
		cmds.setAttr(topoReader+".uvs", jobInfo.useUVs)
		if jobInfo.useFaceSets:
			cmds.ExocortexAlembic_createFaceSets(o=shape, f=jobInfo.filename, i=identifier)

		if useDynTopo:
			cmds.connectAttr(jobInfo.timeCtrl+".outTime", topoReader+".inTime")
			reader = topoReader
		elif not isConstant:
			reader = cmds.deformer(shape, type="ExocortexAlembicPolyMeshDeform")[0]
			setupReaderAttribute(reader, identifier, isConstant, jobInfo)

		#if not useDynTopo:
		#	setupReaderAttribute(topoReader, identifier, isConstant, jobInfo)

	except Exception as ex:
		shape = "?importPolyMesh --> exception: \"" + str(ex.args) + "\" of type " + str(type(ex));
		apix.MPxCommand.setResult(shape)
	cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._import.importPolyMesh")
	return shape
コード例 #3
0
def importPolyMesh(name, identifier, jobInfo, parentXform=None, isConstant=False, useDynTopo=False):
	cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._import.importPolyMesh")

	# TODO: set isConstant properly elsewhere when there are no transforms but are
	# animated attributes
	isConstant = False
	try:
		reader = ""
		shape  = fnt.alembicCreateNode(name, "mesh", parentXform)
		cmds.sets(shape, e=True, forceElement="initialShadingGroup")

		topoReader = cmds.createNode("ExocortexAlembicPolyMesh")
		cmds.connectAttr(topoReader+".outMesh", shape+".inMesh")
		cmds.connectAttr(jobInfo.filenode+".outFileName", topoReader+".fileName")
		cmds.setAttr(topoReader+".identifier", identifier, type="string")
		cmds.setAttr(topoReader+".normals", jobInfo.useNormals)
		cmds.setAttr(topoReader+".uvs", jobInfo.useUVs)
		if jobInfo.useFaceSets:
			cmds.ExocortexAlembic_createFaceSets(o=shape, f=jobInfo.filename, i=identifier)

		if useDynTopo:
			cmds.connectAttr(jobInfo.timeCtrl+".outTime", topoReader+".inTime")
			reader = topoReader
		elif not isConstant:
			reader = cmds.deformer(shape, type="ExocortexAlembicPolyMeshDeform")[0]
			setupReaderAttribute(reader, identifier, isConstant, jobInfo)

		#if not useDynTopo:
		#	setupReaderAttribute(topoReader, identifier, isConstant, jobInfo)

	except:
		return [traceback.format_exc()]
	finally:
		cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._import.importPolyMesh")
	return [shape, reader]
コード例 #4
0
def attachPolyMesh(name, identifier, jobInfo, isConstant=False):
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._attach.attachPolyMesh")
    try:
        if cmds.objectType(name) != "mesh":
            return ["!", "Only mesh can be attached too!"]

        conX = cmds.listConnections(name,
                                    d=False,
                                    type="ExocortexAlembicPolyMeshDeform")
        if conX:  # it's already attached to a deform, simply change the file reference
            polyObj = conX[0]
            attachTimeAndFile(polyObj, jobInfo, isConstant)
            return [polyObj]

        # create deformer, and attach time and file
        newDform = cmds.deformer(name,
                                 type="ExocortexAlembicPolyMeshDeform")[0]
        cmds.setAttr(newDform + ".identifier", identifier, type="string")
        attachTimeAndFile(newDform, jobInfo, isConstant)

        if jobInfo.useFaceSets:
            cmds.ExocortexAlembic_createFaceSets(
                f=cmds.getAttr(jobInfo.filenode + ".outFileName"),
                i=identifier,
                o=name)
    except:
        return ["!", traceback.format_exc()]
    finally:
        cmds.ExocortexAlembic_profileEnd(
            f="Python.ExocortexAlembic._attach.attachPolyMesh")
    return [newDform]