Ejemplo n.º 1
0
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]
Ejemplo n.º 2
0
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]
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
0
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]
Ejemplo n.º 7
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
Ejemplo n.º 8
0
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]
Ejemplo n.º 9
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,
         userAttrs="",
         userAttrPrefixes=""):
    """
	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))

    if userAttrs:
        job += ";userattrs=" + str(userAttrs)
    if userAttrPrefixes:
        job += ";userattrprefixes=" + str(userAttrPrefixes)

    cmds.ExocortexAlembic_export(j=job)
    cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._export.doIt")