コード例 #1
0
def arnold_render_picture():
    """
        Render tea pot to png file and create a log file.

        Parameters
        ----------

        Returns
        -------
            True (Boolean): Always return True if completed

    """

    AiBegin()

    AiMsgSetConsoleFlags(AI_LOG_INFO)

    AiMsgInfo('Starting Rendering ')

    # set output file format & prefix
    cmds.setAttr("defaultArnoldDriver.ai_translator", "png", type="string")
    cmds.setAttr("defaultArnoldDriver.pre", "teapot", type="string")

    # set output log filename path
    cmds.setAttr("defaultArnoldRenderOptions.log_filename",
                 os.path.join(os.path.dirname(__file__), "logs/arnold.log"),
                 type="string")

    # render frame
    arnoldRender(400, 400, True, True, 'persp', ' -layer defaultRenderLayer')

    AiMsgInfo('Rendering complet ! ')

    AiEnd()
    return True
コード例 #2
0
	def tryArnoldRender(self, frame):
		try:
			ma.setAttr("defaultArnoldDriver.ai_translator", self._fileType, type="string")
			ma.setAttr("defaultArnoldDriver.pre", self._fileName, type="string")
			arnoldRender(self._resolutionW, self._resolutionH, True, True, self._getCam(frame), ' -layer defaultRenderLayer')
			return True
		except RuntimeError:
			return False
コード例 #3
0
def render_to(file_path):
    from mtoa.cmds.arnoldRender import arnoldRender
    import pymel.core as pm

    pm.setAttr("defaultArnoldDriver.pre", file_path, type="string")
    arnoldRender(960, 540, True, True, "rendercam",
                 " -layer defaultRenderLayer")
    return file_path + ".png"
コード例 #4
0
def renderThumbnail():
    # arnold render
    from mtoa.cmds.arnoldRender import arnoldRender
    cmds.loadPlugin('mtoa')
    cmds.setAttr("defaultArnoldDriver.ai_translator", "png", type="string")
    cmds.setAttr("defaultArnoldDriver.pre", rndFile, type="string")
    arnoldRender(200, 200, True, True, 'RND_Camera',
                 ' -layer defaultRenderLayer')
コード例 #5
0
def rosiesFunction():
    renderCamera = cmds.camera(name="renderCamera")
    cmds.rename(renderCamera[0], "renderCamera")

    DirectionalLight = maya.cmds.directionalLight(rotation=(-30, -10, -15))

    arnoldRender(1, 1, True, True,'renderCamera', ' -layer defaultRenderLayer')
    cmds.setAttr("defaultArnoldDriver.ai_translator", "png", type="string")
    cmds.setAttr("defaultArnoldDriver.pre", "file_name", type="string")
    arnoldRender(1980, 1024, True, True,'renderCamera', ' -layer defaultRenderLayer')
コード例 #6
0
def hyperRender():

    gamma = mc.floatSliderGrp("gamma", q=True, v=True)

    width = mc.intFieldGrp("Resolution", q=True, value1=True)
    height = mc.intFieldGrp("Resolution", q=True, value2=True)
    fr = mc.textFieldButtonGrp("setFile", q=True, text=True) + "/"

    mc.eval

    mc.select(lights)
    mc.select(meshes, add=True)

    mc.showHidden(a=True)
    for m in meshes:
        hideChildren(m)
    for l in lights:
        mc.hide(l)
    for mesh in meshes:
        # hideChildren(mesh)
        for light in lights:

            mc.select(cl=True)
            mc.select(mesh)
            mc.select(light, add=True)
            showChildren(mesh)
            mc.showHidden(light)
            name = mesh + light + "output"

            mc.setAttr("defaultArnoldDriver.ai_translator",
                       "png",
                       type="string")
            mc.setAttr("defaultArnoldDriver.pre", name, type="string")
            arnoldRender(width, height, True, True, 'RenderCam_',
                         ' -layer defaultRenderLayer')
            #render stuff here
            editor = 'renderView'
            #render_output = mc.renderer(editor, e=True)

            # mc.eval('renderWindowRender redoPreviousRender renderView')
            # editor = 'renderView'
            formatManager = createImageFormats.ImageFormats()
            formatManager.pushRenderGlobalsForDesc("PNG")
            mc.renderWindowEditor(editor,
                                  e=True,
                                  ga=gamma,
                                  com=True,
                                  cme=True,
                                  writeImage=fr + name + '.png')
            exec("print 'file saved to' + fr+name+'.png'")
            formatManager.popRenderGlobals()

            mc.hide(light)
            hideChildren(mesh)
コード例 #7
0
def render(file_,
           camera=None,
           layer='defaultRenderLayer',
           col_mgt=True,
           force=False,
           verbose=0):
    """Render the current scene.

    Args:
        file_ (str): path to save rendered image
        camera (str): camera to render through
        layer (str): layer to render
        col_mgt (bool): apply colour management
        force (bool): replace existing without confirmation
        verbose (int): print process data
    """
    from maya_psyhive import open_maya as hom
    cmds.loadPlugin('mtoa', quiet=True)
    from mtoa.cmds import arnoldRender

    _cam = camera
    if not _cam:
        _cam = hom.get_active_cam()

    # Prepare output path
    _file = File(get_path(file_))
    _file.test_dir()
    _file.delete(force=force, wording='Replace')

    # Prepare arnold
    cmds.setAttr("defaultArnoldRenderOptions.abortOnError", False)
    cmds.setAttr("defaultArnoldDriver.colorManagement", int(col_mgt))
    cmds.setAttr("defaultArnoldDriver.mergeAOVs", True)
    _extn = {'jpg': 'jpeg'}.get(_file.extn, _file.extn)
    cmds.setAttr('defaultArnoldDriver.aiTranslator', _extn, type='string')
    cmds.setAttr('defaultArnoldDriver.prefix',
                 "{}/{}".format(_file.dir, _file.basename),
                 type='string')
    cmds.setAttr("defaultRenderGlobals.animation", False)

    # Execute renders
    assert not _file.exists()
    arnoldRender.arnoldRender(640, 640, True, True, _cam, ' -layer ' + layer)
    if not _file.exists():
        _tmp_file = File('{}/{}_1.{}'.format(_file.dir, _file.basename,
                                             _file.extn))
        print ' - TMP FILE', _tmp_file.path
        assert _tmp_file.exists()
        _tmp_file.move_to(_file)
    assert _file.exists()
    lprint('RENDERED IMAGE', _file.path, verbose=verbose)
コード例 #8
0
ファイル: animkit_zoetrope.py プロジェクト: Errrneist/AnimKit
def render_frame(width,
                 height,
                 frame,
                 file_format="tif",
                 render_layer="defaultRenderLayer",
                 image_padding=get_padding()):
    '''
    HELPER for batch_render().
    Render the selected frame into scene_folder/renders/render_layer/ folder.
    '''
    # ====================================== Cache defaultArnoldDriver.pre ======================================
    frame = int(frame)
    print("[Zoetrope] Frame Renderer - Currently rendering frame " +
          str(frame) + " .")
    cache_defaultArnoldDriver_pre()

    # ====================================== Render the frame ======================================
    file_dir = (sceneName().parent + "\\renders\\" + render_layer).replace(
        '\\', '/')
    prepend = os.path.basename(sceneName()).split('.')[0]
    cmds.setAttr("defaultArnoldDriver.ai_translator",
                 file_format,
                 type="string")
    cmds.setAttr("defaultArnoldDriver.pre",
                 file_dir + "\\" + prepend,
                 type="string")
    cmds.setAttr("render_camShape.mask", 1)
    arnoldRender(width, height, True, True, 'render_cam',
                 ' -layer ' + render_layer)

    # ====================================== Fix the weird _1_ bug ======================================
    # Known bug: The result file generated by arnoldRender() adds a _1_ to the file name
    bug = "_1_"  # idk whyyyy does this happen
    prefix_image_dir = file_dir + "\\" + prepend + bug + "{:0>4d}".format(
        frame) + "." + file_format
    postfix_image_dir = file_dir + "\\" + prepend + "_" + "{:0>4d}".format(
        frame) + "." + file_format
    # print("[Zoetrope] Frame Renderer - Prefix Image Directory: " + prefix_image_dir)  # Debug
    # print("[Zoetrope] Frame Renderer - Postfix Image Directory: " + postfix_image_dir)  # Debug

    if os.path.exists(postfix_image_dir):
        os.remove(postfix_image_dir)
        if not os.path.exists(postfix_image_dir):
            print("[Zoetrope] Frame Renderer - Image exists at: " +
                  postfix_image_dir + " and got deleted successfully.")

    os.rename(prefix_image_dir, postfix_image_dir)

    # ====================================== Reset defaultArnoldDriver.pre ======================================
    set_defaultArnoldDriver_pre()
コード例 #9
0
ファイル: maya.py プロジェクト: Aderemi-Adesada/dccutils
    def take_render_screenshot(self,
                               renderer,
                               output_path,
                               extension,
                               use_view_transform=True):
        """
        Take a render.
        """
        string_ext, id_ext = extension
        self.set_current_id_extension(int(id_ext))
        cmds.setAttr("defaultRenderGlobals.imageFilePrefix",
                     output_path,
                     type="string")
        camera = self.get_camera()
        layer = "-layer defaultRenderLayer "
        if self.is_color_management_available(renderer):
            self.activate_color_management(use_view_transform)

        if renderer == "mayaSoftware":
            command = "render"
            tmp_output_path = mel.eval(command + layer + camera)
            cmds.sysFile(tmp_output_path, rename=output_path)

        elif renderer == "arnold":
            from mtoa.cmds.arnoldRender import arnoldRender

            string_ext = "jpeg" if string_ext == "jpg" else string_ext
            cmds.setAttr("defaultArnoldDriver.ai_translator",
                         string_ext,
                         type="string")
            path_without_extension = os.path.splitext(output_path)[0]
            cmds.setAttr("defaultArnoldDriver.pre",
                         path_without_extension,
                         type="string")
            arnoldRender(1920, 1080, True, True, camera, layer)

        elif renderer == "your_favourite_renderer":
            # Launch the render...
            pass
        else:
            raise RenderNotSupported(
                "The %s renderer is currently not supported. "
                "But you can still adapt the code to make the render accessible. "
                "You might want to look at the file %s" % (renderer, __file__))
コード例 #10
0
def renderImage(width, height):
    aR.arnoldRender(width, height, True, True, 'PBRCam', [ '-ofn "test"' ])
コード例 #11
0
from mtoa.cmds.arnoldRender import arnoldRender
arnoldRender(1920, 1080, True, True, 'camera1', ' -layer defaultRenderLayer')
arnoldRender(960, 720, True, True, 'camera1', ' -layer defaultRenderLayer')