def confirmWritePropReference(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
        ]
        exportPropJSON(filePath,
                       non_cameras[0],
                       isReference=False,
                       name=body.get_name())
        showSuccessPopup()
Exemple #2
0
def get_link(element=None, dept=None):

    if element is None:
        filePath = pm.sceneName()
        fileDir = os.path.dirname(filePath)
        proj = Project()
        checkout = proj.get_checkout(fileDir)
        # Make sure we have access to element data for this asset
        if checkout is None:
            message_gui.error(
                "Nothing is checked out.",
                "You must check out a model in order to see it's SketchFab link."
            )
            return None
        else:
            body_name = checkout.get_body_name()
            dept_name = checkout.get_department_name()
            elem_name = checkout.get_element_name()
            body = proj.get_body(body_name)
            element = body.get_element(dept_name, name=elem_name)

    #Get the element from the right Department
    if dept is not None and not element.get_department() == dept:
        print 'We are overwriting the', element.get_department(), 'with', dept
        body = proj.get_body(element.get_parent())
        element = body.get_element(dept)

    if element is None:
        message_gui.error("Nothing is checked out.",
                          "There is no element associated with this asset.")
        return

    proj = Project()
    body_name = element.get_parent()
    body = proj.get_body(body_name)
    asset_file_path = element.get_dir()
    uid_file_path = '{0}/{1}.json'.format(asset_file_path, body_name)
    if not os.path.exists(uid_file_path):
        message_gui.error(
            "No SketchFab link was found.",
            "Either nothing was exported to SketchFab, or something went wrong during export."
        )
        return

    model_uid = ''

    try:
        with open(uid_file_path) as uid_file:
            uid_file_data = json.load(uid_file)
        model_uid = uid_file_data['uid']
    except ValueError:
        message_gui.error("The SketchFab link is broken :(",
                          "You'll need to talk to pipeline about this.")
        return

    global SKETCHFAB_MODEL_URL
    model_url = SKETCHFAB_MODEL_URL + model_uid
    message_gui.input('Link:', 'SketchFab Link', model_url)
def go(body=None, type=AssetType.SET):
    if not body:
        parent = publish.maya_main_window()
        filePath = pm.sceneName()
        fileDir = os.path.dirname(filePath)
        project = Project()
        checkout = project.get_checkout(fileDir)
        if not checkout:
            filePath = Environment().get_user_workspace()
            filePath = os.path.join(filePath, 'untitled.mb')
            filePath = pipeline_io.version_file(filePath)

        global maya_publish_dialog
        selection_list = []
        if type == "shot":
            selection_list = Project().list_shots()
        elif type == AssetType.PROP:
            selection_list = []
            for asset in Project().list_assets():
                body = project.get_body(asset)
                if body.get_type() != AssetType.PROP:
                    continue
                selection_list.append(asset)
        elif type == AssetType.SET:
            selection_list = Project().list_sets()
        else:
            print("Didn't export JSON, because it probably is a character.")
            return

        maya_publish_dialog = SelectFromList(parent=maya_main_window())
        maya_publish_dialog.setWindowTitle("Select shot" if type ==
                                           "shot" else "Select prop" if type ==
                                           AssetType.PROP else "Select set")
        maya_publish_dialog.setList(selection_list)
        maya_publish_dialog.filePath = filePath
        maya_publish_dialog.selected.connect(publish_submitted)
        maya_publish_dialog.show()
    else:
        if type == "shot":
            confirmWriteShotReferences(body)
        elif type == AssetType.PROP:
            confirmWritePropReference(body)
        elif type == AssetType.SET:
            confirmWriteSetReferences(body)
Exemple #4
0
def go(element=None, dept=None):

    pm.loadPlugin('fbxmaya.so')
    if not pm.sceneName() == '':
        pm.saveFile(force=True)

    if element is None:
        filePath = pm.sceneName()
        fileDir = os.path.dirname(filePath)
        proj = Project()
        checkout = proj.get_checkout(fileDir)
        # Make sure we have access to element data for this asset
        if checkout is None:
            message_gui.error(
                "Nothing is checked out.",
                "You must check out a model in order to publish it to SketchFab."
            )
            return None
        else:
            body_name = checkout.get_body_name()
            dept_name = checkout.get_department_name()
            elem_name = checkout.get_element_name()
            body = proj.get_body(body_name)
            element = body.get_element(dept_name, name=elem_name)

    #Get the element from the right Department
    if dept is not None and not element.get_department() == dept:
        print 'We are overwriting the', element.get_department(), 'with', dept
        body = proj.get_body(element.get_parent())
        element = body.get_element(dept)

    if element is None:
        print "Nothing is selected."
        return

    if not element.get_department() == Department.MODEL:
        message_gui.error(
            "We can only publish models to sketchFab (no rigs).",
            "Please check out a model (sets included) if you wish to publish to SketchFab."
        )
    else:
        export(element)
def go():

    project = Project()
    filepath = cmds.file(q=True, sceneName=True)

    checkout = project.get_checkout(os.path.dirname(filepath))
    if checkout is not None:
        body_name = checkout.get_body_name()
        body = project.get_body(body_name)
        if body.is_shot():
            frame_range = body.get_frame_range()
            if frame_range > 0:
                print "set frame range to " + str(frame_range)
                cmds.playbackOptions(animationStartTime=1.0, animationEndTime=frame_range, minTime=1.0, maxTime=frame_range, framesPerSecond=24)
            else:
                print "shot has invalid frame range"
        else:
            print "not a shot"  
    else:
        print "Unknown Shot, can't set frame range"
def confirmWriteShotReferences(body=None):

    #response = showConfirmationPopup()
    #if response == "Yes":
    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())
        export_shot(refsFilePath)
    else:
        print("NOT A SHOT")
        showFailurePopup('No set found in current scene.')
Exemple #7
0
def go(element=None,
       dept=None,
       selection=None,
       startFrame=None,
       endFrame=None):
    pm.loadPlugin('AbcExport')

    if not pm.sceneName() == '':
        pm.saveFile(force=True)

    if element is None:
        filePath = pm.sceneName()
        fileDir = os.path.dirname(filePath)
        proj = Project()
        checkout = proj.get_checkout(fileDir)
        if checkout is None:
            parent = QtWidgets.QApplication.activeWindow()
            element = selection_gui.getSelectedElement(parent)
            if element is None:
                return None
        else:
            bodyName = checkout.get_body_name()
            deptName = checkout.get_department_name()
            elemName = checkout.get_element_name()
            body = proj.get_body(bodyName)
            element = body.get_element(deptName, name=elemName)

    #Get the element from the right Department
    if dept is not None and not element.get_department() == dept:
        print 'We are overwriting the', element.get_department(), 'with', dept
        body = proj.get_body(element.get_parent())
        element = body.get_element(dept)

    return export(element,
                  selection=selection,
                  startFrame=startFrame,
                  endFrame=endFrame)
Exemple #8
0
def go():

    project = Project()
    filepath = cmds.file(q=True, sceneName=True)

    checkout = project.get_checkout(os.path.dirname(filepath))
    if checkout is not None:
        body_name = checkout.get_body_name()
        body = project.get_body(body_name)
        if body.is_shot():
            frame_range = body.get_frame_range()
            if frame_range > 0:
                print "set frame range to " + str(frame_range)
                cmds.playbackOptions(animationStartTime=1.0,
                                     animationEndTime=frame_range,
                                     minTime=1.0,
                                     maxTime=frame_range,
                                     framesPerSecond=24)
            else:
                print "shot has invalid frame range"
        else:
            print "not a shot"
    else:
        print "Unknown Shot, can't set frame range"