Пример #1
0
    def confirmWritePropReference(self, body=None):
        filepath = pm.sceneName()
        fileDir = os.path.dirname(filepath)
        project = Project()

        if not body:
            checkout = project.get_checkout(fileDir)
            bodyName = checkout.get_body_name()
            body = project.get_body(bodyName)

        if body.is_asset() and body.get_type() == AssetType.PROP:
            element = body.get_element(Department.MODEL)
            filepath = os.path.join(project.get_assets_dir(),
                                    element.get_cache_dir())
            assemblies = pm.ls(assemblies=True)
            pm.select(pm.listCameras(), replace=True)
            cameras = pm.selected()
            pm.select([])
            non_cameras = [
                assembly for assembly in assemblies if assembly not in cameras
            ]
            self.exportPropJSON(filepath,
                                non_cameras[0],
                                isReference=False,
                                name=body.get_name())
            print("JSON references written successfully.")
Пример #2
0
    def generateGeometry(self, path='',element=None):
    	'''
    		Function for generating geometry for Maya files.
    		Creates the following output formats:
    			.obj
    		@return: True if all files were created successfully
    				False if some files were not created
    		@post: Missing filenames are printed out to both the Maya terminal as well
    				as presented in a Maya confirm dialog.
    	'''

    	path = os.path.dirname(mc.file(q=True, sceneName=True))
    	if not os.path.exists (os.path.join(path, 'cache')):
    		os.makedirs(os.path.join(path, 'cache'))

    	ABCPATH = os.path.join(path, 'cache', 'abcFiles')

    	if os.path.exists(ABCPATH):
    		shutil.rmtree(ABCPATH)

    	filePath = mc.file(q=True, sceneName=True)
    	fileDir = os.path.dirname(filePath)

    	abcFilePath = self.getElementCacheDirectory(fileDir, element)
    	if abcFilePath is None:
    		return False

    	selection = mc.ls(geometry=True, visible=True)
    	selection_long = mc.ls(geometry=True, visible=True, long=True)

    	project = Project()
    	if element is None:
    		checkout = project.get_checkout(path)
    		if checkout is None:
    			qd.error('There was a problem exporting the alembic to the correct location. Checkout the asset again and try one more time.')
    			return None
    		body = project.get_body(checkout.get_body_name())
    		element = body.get_element(checkout.get_department_name(), checkout.get_element_name())
    	else:
    		body = project.get_body(element.get_parent())

    	# We decided to try exporting all the geo into one alembic file instead of many. This is the line that does many
    	# abcs = abcExport(selection_long, ABCPATH)
    	# if body.is_asset():
    	# 	if body.get_type() == AssetType.SET:
    	# 		abcs = self.abcExportLoadedReferences(ABCPATH)
    	# 	else:
    	# 		abcs = self.abcExportAll(element.get_long_name(), ABCPATH)
    	# else:

    	abcs = self.abcExportAll(element.get_long_name(), ABCPATH)

    	if not len(self.checkFiles(abcs)) == 0:
    		return False

    	return True
Пример #3
0
    def getElementCacheDirectory(self, path, element=None):

    	if element is None:
    		project = Project()
    		checkout = project.get_checkout(path)
    		if checkout is None:
    			qd.error('There was a problem exporting the alembic to the correct location. Checkout the asset again and try one more time.')
    			return None
    		body = project.get_body(checkout.get_body_name())
    		element = body.get_element(checkout.get_department_name(), checkout.get_element_name())

    	return element.get_cache_dir()
Пример #4
0
    def confirmWriteShotReferences(self, body=None):
        filePath = pm.sceneName()
        filDir = os.path.dirname(filePath)
        proj = Project()
        if not body:
            checkout = proj.get_checkout(fileDir)
            bodyName = checkout.get_body_name()
            body = proj.get_body(bodyName)

        if body.is_shot():
            print("SHOT OK")
            element = body.get_element(Department.ANIM)
            refsFilePath = os.path.join(Project().get_assets_dir(), element.get_cache_dir())
            self.export_shot(refsFilePath)
        else:
            print("NOT A SHOT")
            qd.error('No set found in current scene.')
Пример #5
0
    def confirmWriteSetReferences(self, body=None):
        filePath = pm.sceneName()
        fileDir = os.path.dirname(filePath)
        proj = Project()
        if not body:
            checkout = proj.get_checkout(fileDir)
            bodyName = checkout.get_body_name()
            body = proj.get_body(bodyName)

        if body.is_asset():
            if body.get_type() == AssetType.SET:
                print("SET OK")
                element = body.get_element(Department.MODEL)
                refsFilePath = os.path.join(Project().get_assets_dir(), element.get_cache_dir())
                self.exportReferences(refsFilePath)
                qd.info("JSON references written successfully.")
            else:
                print("NOT A SET")
                qd.error('No set found in current scene.')