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]
Beispiel #2
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
def attachPoints(name, identifier, jobInfo, isConstant=False):
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._attach.attachPoints")
    try:
        conX = cmds.listConnections(name,
                                    d=False,
                                    type="ExocortexAlembicPoints")
        if conX:
            ptsObj = conX[0]
            attachTimeAndFile(ptsObj, jobInfo, isConstant)
            return [ptsObj]

        reader = cmds.createNode("ExocortexAlembicPoints")
        cmds.addAttr(name, ln="rgbPP", dt="vectorArray")
        cmds.addAttr(name, ln="opacityPP", dt="doubleArray")
        cmds.addAttr(name, ln="agePP", dt="doubleArray")
        cmds.addAttr(name, ln="shapeInstanceIdPP", dt="doubleArray")
        cmds.addAttr(name, ln="orientationPP", dt="vectorArray")
        cmds.connectAttr(reader + ".output[0]", name + ".newParticles[0]")
        cmds.connectAttr(jobInfo.timeCtrl + ".outTime", name + ".currentTime")
        cmds.setAttr(name + ".conserve", 0)

        attachTimeAndFile(reader, jobInfo, isConstant)
    except:
        return ["!", traceback.format_exc()]
    finally:
        cmds.ExocortexAlembic_profileEnd(
            f="Python.ExocortexAlembic._attach.attachPoints")
    return [reader]
Beispiel #4
0
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
Beispiel #5
0
def attachCurves(name, identifier, jobInfo, isConstant=False):
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._attach.attachCurves")
    if cmds.objExists(name):
        curObj = cmds.connectionInfo(name + ".visibility", sfd=True)
        if curObj and cmds.objectType(
                curObj) == "ExocortexAlembicCurvesDeform":
            attachTimeAndFile(curObj, jobInfo, isConstant)
            return

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

        # get curObj new "output" attribute connection
        if cmds.objExists(curObj):
            if curObj != None and cmds.objectType(
                    curObj) != "ExocortexAlembicCurves":
                originalCur = cmds.connectionInfo(curObj + ".output",
                                                  sfd=True).split('.')[0]

                cmds.delete(curObj)
                curObj = cmds.createNode("ExocortexAlembicCurves")
                attachTimeAndFile(curObj, jobInfo, isConstant)

                cmds.connectAttr(curObj + ".outCurve", originalCur + ".create")
                cmds.connectAttr(jobInfo.filenode + ".outFileName",
                                 curObj + ".fileName")
                cmds.setAttr(curObj + ".identifier", identifier, type="string")

    cmds.ExocortexAlembic_profileEnd(
        f="Python.ExocortexAlembic._attach.attachCurves")
    pass
Beispiel #6
0
def importPoints(name,
                 identifier,
                 jobInfo,
                 parentXform=None,
                 isConstant=False):
    try:
        cmds.ExocortexAlembic_profileBegin(
            f="Python.ExocortexAlembic._import.importPoints")
        shape = fnt.alembicCreateNode(name, "particle", parentXform)
        reader = cmds.createNode("ExocortexAlembicPoints")

        cmds.addAttr(shape, ln="rgbPP", dt="vectorArray")
        cmds.addAttr(shape, ln="opacityPP", dt="doubleArray")
        cmds.addAttr(shape, ln="agePP", dt="doubleArray")
        cmds.addAttr(shape, ln="shapeInstanceIdPP", dt="doubleArray")
        cmds.addAttr(shape, ln="orientationPP", dt="vectorArray")
        cmds.connectAttr(reader + ".output[0]", shape + ".newParticles[0]")
        cmds.connectAttr(jobInfo.timeCtrl + ".outTime", shape + ".currentTime")
        cmds.setAttr(shape + ".conserve", 0)

        setupReaderAttribute(reader, identifier, isConstant, jobInfo)
    except Exception as ex:
        shape = "?importPoints --> exception: \"" + str(
            ex.args) + "\" of type " + str(type(ex))
        apix.MPxCommand.setResult(shape)
    cmds.ExocortexAlembic_profileEnd(
        f="Python.ExocortexAlembic._import.importPoints")
    return shape
def importCamera(name, identifier, jobInfo, parentXform=None, isConstant=False):
	cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._import.importCamera")
	# TODO: set isConstant properly elsewhere when there are no transforms but are
	# animated attributes
	isConstant = False
	try:
		shape 	= fnt.alembicCreateNode(name, "camera", parentXform)
		reader 	= cmds.createNode("ExocortexAlembicCamera")

		cmds.connectAttr(reader+".focalLength", shape+".focalLength")
		cmds.connectAttr(reader+".focusDistance", shape+".focusDistance")
		cmds.connectAttr(reader+".lensSqueezeRatio", shape+".lensSqueezeRatio")
		cmds.connectAttr(reader+".horizontalFilmAperture", shape+".horizontalFilmAperture")
		cmds.connectAttr(reader+".verticalFilmAperture", shape+".verticalFilmAperture")
		cmds.connectAttr(reader+".horizontalFilmOffset", shape+".horizontalFilmOffset")
		cmds.connectAttr(reader+".verticalFilmOffset", shape+".verticalFilmOffset")
		cmds.connectAttr(reader+".fStop", shape+".fStop")
		cmds.connectAttr(reader+".shutterAngle", shape+".shutterAngle")

		setupReaderAttribute(reader, identifier, isConstant, jobInfo)
	except:
		return [traceback.format_exc()]
	finally:
		cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._import.importCamera")
	return [shape, reader]
Beispiel #8
0
def importCurves(name,
                 identifier,
                 jobInfo,
                 parentXform=None,
                 isConstant=False,
                 nbCurves=1):
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._import.importCurves")
    try:
        topoReader = cmds.createNode("ExocortexAlembicCurves")
        cmds.connectAttr(jobInfo.filenode + ".outFileName",
                         topoReader + ".fileName")
        cmds.connectAttr(jobInfo.timeCtrl + ".outTime", topoReader + ".inTime")
        cmds.setAttr(topoReader + ".identifier", identifier, type="string")

        shape = fnt.alembicCreateNode(name, "nurbsCurve", parentXform)
        cmds.connectAttr(topoReader + ".outCurve[0]", shape + ".create")
        for curve in xrange(1, nbCurves):
            shape = fnt.alembicCreateNode(name + "_" + str(curve),
                                          "nurbsCurve", parentXform)
            cmds.connectAttr(topoReader + ".outCurve[" + str(curve) + "]",
                             shape + ".create")

    except Exception as ex:
        shape = "?importCurves --> exception: \"" + str(
            ex.args) + "\" of type " + str(type(ex))
        apix.MPxCommand.setResult(shape)
    cmds.ExocortexAlembic_profileEnd(
        f="Python.ExocortexAlembic._import.importCurves")
    return shape
Beispiel #9
0
def importCamera(name,
                 identifier,
                 jobInfo,
                 parentXform=None,
                 isConstant=False):
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._import.importCamera")
    try:
        shape = fnt.alembicCreateNode(name, "camera", parentXform)
        reader = cmds.createNode("ExocortexAlembicCamera")

        cmds.connectAttr(reader + ".focalLength", shape + ".focalLength")
        cmds.connectAttr(reader + ".focusDistance", shape + ".focusDistance")
        cmds.connectAttr(reader + ".lensSqueezeRatio",
                         shape + ".lensSqueezeRatio")
        cmds.connectAttr(reader + ".horizontalFilmAperture",
                         shape + ".horizontalFilmAperture")
        cmds.connectAttr(reader + ".verticalFilmAperture",
                         shape + ".verticalFilmAperture")
        cmds.connectAttr(reader + ".horizontalFilmOffset",
                         shape + ".horizontalFilmOffset")
        cmds.connectAttr(reader + ".verticalFilmOffset",
                         shape + ".verticalFilmOffset")
        cmds.connectAttr(reader + ".fStop", shape + ".fStop")
        cmds.connectAttr(reader + ".shutterAngle", shape + ".shutterAngle")

        setupReaderAttribute(reader, identifier, isConstant, jobInfo)
    except Exception as ex:
        shape = "?importCamera --> exception: \"" + str(
            ex.args) + "\" of type " + str(type(ex))
        apix.MPxCommand.setResult(shape)
    cmds.ExocortexAlembic_profileEnd(
        f="Python.ExocortexAlembic._import.importCamera")
    return shape
def attachCamera(name, identifier, jobInfo, isConstant=False):
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._attach.attachCamera")
    try:
        conX = cmds.listConnections(name,
                                    d=False,
                                    type="ExocortexAlembicCamera")
        if conX:
            camObj = conX[0]
            attachTimeAndFile(camObj, jobInfo, isConstant)
            return [camObj]

        reader = cmds.createNode("ExocortexAlembicCamera")
        cmds.connectAttr(reader + ".focalLength", name + ".focalLength")
        cmds.connectAttr(reader + ".focusDistance", name + ".focusDistance")
        cmds.connectAttr(reader + ".lensSqueezeRatio",
                         name + ".lensSqueezeRatio")
        cmds.connectAttr(reader + ".horizontalFilmAperture",
                         name + ".horizontalFilmAperture")
        cmds.connectAttr(reader + ".verticalFilmAperture",
                         name + ".verticalFilmAperture")
        cmds.connectAttr(reader + ".horizontalFilmOffset",
                         name + ".horizontalFilmOffset")
        cmds.connectAttr(reader + ".verticalFilmOffset",
                         name + ".verticalFilmOffset")
        cmds.connectAttr(reader + ".fStop", name + ".fStop")
        cmds.connectAttr(reader + ".shutterAngle", name + ".shutterAngle")

        attachTimeAndFile(reader, jobInfo, isConstant)
    except:
        return ["!", traceback.format_exc()]
    finally:
        cmds.ExocortexAlembic_profileEnd(
            f="Python.ExocortexAlembic._attach.attachCamera")
    return [reader]
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]
Beispiel #12
0
def attachXform(name, identifier, jobInfo, isConstant=False):
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._attach.attachXform")
    if cmds.objExists(name):
        conX = cmds.listConnections(name + ".translate")
        if conX:
            # already receiving transformation from another node!
            conX = conX[0]
            if cmds.objectType(conX) == "ExocortexAlembicXform":
                attachTimeAndFile(conX, jobInfo, isConstant)
            else:
                print(
                    "Cannot attach Xform to " + name +
                    ", it's attach to a node that is not an \"ExocortexAlembicXform\""
                )
            return

        newXform = cmds.createNode("ExocortexAlembicXform")
        cmds.setAttr(newXform + ".identifier", identifier, type="string")
        cmds.connectAttr(newXform + ".translate", name + ".translate")
        cmds.connectAttr(newXform + ".rotate", name + ".rotate")
        cmds.connectAttr(newXform + ".scale", name + ".scale")
        cmds.connectAttr(newXform + ".outVisibility", name + ".visibility")

        attachTimeAndFile(newXform, jobInfo, isConstant)
        cmds.ExocortexAlembic_profileEnd(
            f="Python.ExocortexAlembic._attach.attachXform")
Beispiel #13
0
def attachCamera(name, identifier, jobInfo, isConstant=False):
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._attach.attachCamera")
    camObj = cmds.connectionInfo(name + ".focalLength", sfd=True)
    if camObj and cmds.objectType(camObj) == "ExocortexAlembicCamera":
        attachTimeAndFile(camObj, jobInfo, isConstant)
        return

    reader = cmds.createNode("ExocortexAlembicCamera")
    cmds.connectAttr(reader + ".focalLength", name + ".focalLength")
    cmds.connectAttr(reader + ".focusDistance", name + ".focusDistance")
    cmds.connectAttr(reader + ".lensSqueezeRatio", name + ".lensSqueezeRatio")
    cmds.connectAttr(reader + ".horizontalFilmAperture",
                     name + ".horizontalFilmAperture")
    cmds.connectAttr(reader + ".verticalFilmAperture",
                     name + ".verticalFilmAperture")
    cmds.connectAttr(reader + ".horizontalFilmOffset",
                     name + ".horizontalFilmOffset")
    cmds.connectAttr(reader + ".verticalFilmOffset",
                     name + ".verticalFilmOffset")
    cmds.connectAttr(reader + ".fStop", name + ".fStop")
    cmds.connectAttr(reader + ".shutterAngle", name + ".shutterAngle")

    attachTimeAndFile(reader, jobInfo, isConstant)
    cmds.ExocortexAlembic_profileEnd(
        f="Python.ExocortexAlembic._attach.attachCamera")
    pass
Beispiel #14
0
def alembicCreateNode(name, type, parentXform=None):
    """ create a node and make sure to return a full name and create namespaces if necessary! """
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._functions.createAlembicNode")
    #print("alembicCreateNode(" + str(name) + ", " + str(type) + ", " + str(parentXform) + ")")
    result = subCreateNode(name.split('|'), type, parentXform)
    cmds.ExocortexAlembic_profileEnd(
        f="Python.ExocortexAlembic._functions.createAlembicNode")
    return result
Beispiel #15
0
def doIt(filename,
         exInframe,
         exOutframe,
         exObjects=None,
         exStepframe=1,
         exSubstepframe=1,
         exTopology=3,
         exUVs=True,
         exFaceSets=True,
         exDynTopo=False,
         exGlobSpace=False,
         exWithoutHierarchy=False,
         exXformCache=False,
         exUseInitShadGrp=False,
         exUseOgawa=False):
    """
	Set up the string parameter for ExocortexAlembic_export
	"""
    def doIt_listExportObjects(exObjects):
        objs = str(exObjects[0])
        for obj in exObjects[1:]:
            objs = objs + "," + str(obj)
        return objs

    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._export.doIt")
    if exObjects == None:
        exObjects = cmds.ls(sl=True)
    job = "in=" + str(exInframe) + ";out=" + str(exOutframe) + ";step=" + str(
        exStepframe) + ";substep=" + str(
            exSubstepframe) + ";filename=" + filename + ";objects=" + (
                doIt_listExportObjects(exObjects)) + ";ogawa=" + str(
                    int(exUseOgawa))

    if exTopology == 1:
        job += ";purepointcache=1;dynamictopology=0;normals=0;uvs=0;facesets=0"
    else:
        job += ";purepointcache=0;uvs=" + str(int(exUVs))
        job += ";facesets="  #+str(int(exFaceSets)) # move this in the if/else just below
        if exFaceSets:
            job += "1;useInitShadGrp=" + str(int(exUseInitShadGrp))
        else:
            job += "0"

        if exTopology == 2:
            job += ";normals=0;dynamictopology=0"
        else:
            job += ";normals=1;dynamictopology=" + str(int(exDynTopo))

    job += ";globalspace=" + str(int(exGlobSpace))
    job += ";withouthierarchy=" + str(int(exWithoutHierarchy))
    job += ";transformcache=" + str(int(exXformCache))

    cmds.ExocortexAlembic_export(j=job)
    cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._export.doIt")
Beispiel #16
0
def alembicConnectAttr(source, target):
    """ make sure nothing is connected the target and then connect the source to the target """
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._functions.alembicConnectIfUnconnected")
    currentSource = cmds.connectionInfo(target, sfd=True)
    if currentSource != "" and currentSource != source:
        cmds.disconnectAttr(currentSource, target)
    cmds.connectAttr(source, target)
    cmds.ExocortexAlembic_profileEnd(
        f="Python.ExocortexAlembic._functions.alembicConnectIfUnconnected")
    pass
Beispiel #17
0
def setupReaderAttribute(reader, identifier, isConstant, jobInfo):
	cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._import.setupReaderAttribute")
	try:
		if reader != "":
			if not isConstant:
				fnt.alembicConnectAttr(jobInfo.timeCtrl+".outTime", reader+".inTime")
			cmds.connectAttr(jobInfo.filenode+".outFileName", reader+".fileName")
			cmds.setAttr(reader+".identifier", identifier, type="string")
	except Exception as ex:
		apix.MPxCommand.setResult("?setupReaderAttribute --> exception: \"" + str(ex.args) + "\" of type " + str(type(ex)))
	cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._import.setupReaderAttribute")
def setupReaderAttribute(reader, identifier, isConstant, jobInfo):
	cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._import.setupReaderAttribute")
	try:
		if reader != "":
			if not isConstant:
				fnt.alembicConnectAttr(jobInfo.timeCtrl+".outTime", reader+".inTime")
			cmds.connectAttr(jobInfo.filenode+".outFileName", reader+".fileName")
			cmds.setAttr(reader+".identifier", identifier, type="string")
	except:
		raise
	finally:
		cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._import.setupReaderAttribute")
Beispiel #19
0
def alembicTimeAndFileNode(filename, multi=False):
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._functions.alembicTimeAndFileNode")
    #print("time control")
    timeControl = "AlembicTimeControl"
    if not cmds.objExists(timeControl):
        timeControl = cmds.createNode("ExocortexAlembicTimeControl",
                                      name=timeControl)
        alembicConnectAttr("time1.outTime", timeControl + ".inTime")
    #print("file node")
    fileNode = cmds.createNode("ExocortexAlembicFile")
    cmds.setAttr(fileNode + ".fileName", filename, type="string")
    cmds.connectAttr(timeControl + ".outTime", fileNode + ".inTime")
    if multi:
        cmds.setAttr(fileNode + ".multiFiles", 1)
    cmds.ExocortexAlembic_profileEnd(
        f="Python.ExocortexAlembic._functions.alembicTimeAndFileNode")
    return fileNode, timeControl
Beispiel #20
0
def importXform(name, identifier, jobInfo, parentXform=None, isConstant=False):
	cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._import.importXform")

	try:
		shape  = fnt.alembicCreateNode(name, "transform", parentXform)
		reader = cmds.createNode("ExocortexAlembicXform")

		cmds.connectAttr(reader+".translate", 		shape+".translate")
		cmds.connectAttr(reader+".rotate", 			shape+".rotate")
		cmds.connectAttr(reader+".scale", 			shape+".scale")
		cmds.connectAttr(reader+".outVisibility",	shape+".visibility")

		setupReaderAttribute(reader, identifier, isConstant, jobInfo)
	except Exception as ex:
		shape = "?importXform --> exception: \"" + str(ex.args) + "\" of type " + str(type(ex));
		apix.MPxCommand.setResult(shape)
	cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._import.importXform")
	return shape
def attachCurves(name, identifier, jobInfo, isConstant=False):
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._attach.attachCurves")
    try:
        conX = (cmds.listConnections(
            name + ".create", d=False, type="ExocortexAlembicCurvesDeform")
                or cmds.listConnections(
                    name + ".create", d=False, type="ExocortexAlembicCurves"))
        if conX:
            curObj = conX[0]
            attachTimeAndFile(curObj, jobInfo, isConstant)
            return [curObj]

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

        # get curObj new "output" attribute connection
        conX = cmds.listConnections(name + ".create",
                                    d=False,
                                    type="ExocortexAlembicCurvesDeform")
        if conX:
            curObj = conX[0]
            originalCur = cmds.connectionInfo(curObj + ".output",
                                              sfd=True).split('.')[0]

            cmds.delete(curObj)
            curObj = cmds.createNode("ExocortexAlembicCurves")
            attachTimeAndFile(curObj, jobInfo, isConstant)

            cmds.connectAttr(curObj + ".outCurve", originalCur + ".create")
            cmds.connectAttr(jobInfo.filenode + ".outFileName",
                             curObj + ".fileName")
            cmds.setAttr(curObj + ".identifier", identifier, type="string")
    except:
        return ["!", traceback.format_exc()]
    finally:
        cmds.ExocortexAlembic_profileEnd(
            f="Python.ExocortexAlembic._attach.attachCurves")
    return [curObj]
def importXform(name, identifier, jobInfo, parentXform=None, isConstant=False):
	cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._import.importXform")

	# TODO: set isConstant properly elsewhere when there are no transforms but are
	# animated attributes
	isConstant = False
	try:
		shape  = fnt.alembicCreateNode(name, "transform", parentXform)
		reader = cmds.createNode("ExocortexAlembicXform")

		cmds.connectAttr(reader+".translate", 		shape+".translate")
		cmds.connectAttr(reader+".rotate", 			shape+".rotate")
		cmds.connectAttr(reader+".scale", 			shape+".scale")
		cmds.connectAttr(reader+".outVisibility",	shape+".visibility")

		setupReaderAttribute(reader, identifier, isConstant, jobInfo)
	except:
		return [traceback.format_exc()]
	finally:
		cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._import.importXform")
	return [shape, reader]
def importCurves(name, identifier, jobInfo, parentXform=None, isConstant=False, nbCurves=1):
	cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._import.importCurves")
	# TODO: set isConstant properly elsewhere when there are no transforms but are
	# animated attributes
	isConstant = False
	try:
		topoReader = cmds.createNode("ExocortexAlembicCurves")
		cmds.connectAttr(jobInfo.filenode+".outFileName", topoReader+".fileName")
		cmds.connectAttr(jobInfo.timeCtrl+".outTime", topoReader+".inTime")
		cmds.setAttr(topoReader+".identifier", identifier, type="string")

		shape  = fnt.alembicCreateNode(name, "nurbsCurve", parentXform)
		cmds.connectAttr(topoReader+".outCurve[0]", shape+".create")
		for curve in xrange(1, nbCurves):
			shape  = fnt.alembicCreateNode(name + "_" + str(curve), "nurbsCurve", parentXform)
			cmds.connectAttr(topoReader+".outCurve[" + str(curve) + "]", shape+".create")

	except:
		return [traceback.format_exc()]
	finally:
		cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._import.importCurves")
	return [shape, topoReader]
Beispiel #24
0
def attachPoints(name, identifier, jobInfo, isConstant=False):
    cmds.ExocortexAlembic_profileBegin(
        f="Python.ExocortexAlembic._attach.attachPoints")
    ptsObj = cmds.connectionInfo(name + ".visibility", sfd=True)
    if ptsObj and cmds.objectType(ptsObj) == "ExocortexAlembicPoints":
        attachTimeAndFile(ptsObj, jobInfo, isConstant)
        return

    reader = cmds.createNode("ExocortexAlembicPoints")
    cmds.addAttr(name, ln="rgbPP", dt="vectorArray")
    cmds.addAttr(name, ln="opacityPP", dt="doubleArray")
    cmds.addAttr(name, ln="agePP", dt="doubleArray")
    cmds.addAttr(name, ln="shapeInstanceIdPP", dt="doubleArray")
    cmds.addAttr(name, ln="orientationPP", dt="vectorArray")
    cmds.connectAttr(reader + ".output[0]", name + ".newParticles[0]")
    cmds.connectAttr(jobInfo.timeCtrl + ".outTime", name + ".currentTime")
    cmds.setAttr(name + ".conserve", 0)

    attachTimeAndFile(reader, jobInfo, isConstant)
    cmds.ExocortexAlembic_profileEnd(
        f="Python.ExocortexAlembic._attach.attachPoints")
    pass
def importPoints(name, identifier, jobInfo, parentXform=None, isConstant=False):
	# TODO: set isConstant properly elsewhere when there are no transforms but are
	# animated attributes
	isConstant = False
	try:
		cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._import.importPoints")
		shape  = fnt.alembicCreateNode(name, "particle", parentXform)
		reader = cmds.createNode("ExocortexAlembicPoints")

		cmds.addAttr(shape, ln="rgbPP", dt="vectorArray")
		cmds.addAttr(shape, ln="opacityPP", dt="doubleArray")
		cmds.addAttr(shape, ln="agePP", dt="doubleArray")
		cmds.addAttr(shape, ln="shapeInstanceIdPP", dt="doubleArray")
		cmds.addAttr(shape, ln="orientationPP", dt="vectorArray")
		cmds.connectAttr(reader+".output[0]", shape+".newParticles[0]")
		cmds.connectAttr(jobInfo.timeCtrl+".outTime", shape+".currentTime")
		cmds.setAttr(shape+".conserve", 0)

		setupReaderAttribute(reader, identifier, isConstant, jobInfo)
	except:
		return [traceback.format_exc()]
	finally:
		cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._import.importPoints")
	return [shape, reader]