Beispiel #1
0
def rebuild_work_stats():
    project_dic = project.read_project()
    asset_version_list = []
    stats().reset_versions_count()

    for domain in project_dic.keys():
        for category in project_dic[domain].keys():
            for name in project_dic[domain][category].keys():
                for stage in project_dic[domain][category][name].keys():
                    asset = asset_core.asset(domain=domain,
                                             category=category,
                                             name=name,
                                             stage=stage)
                    for variant in prefs().asset(asset).stage.variants:
                        if variant and variant != 'None':
                            asset.variant = variant
                            for software in prefs().asset(
                                    asset).stage.softwares:
                                asset.software = software
                                version_list = prefs().asset(
                                    asset).software.versions
                                for version in version_list:
                                    if version != '0000':
                                        asset.version = version
                                        if prefs().asset(
                                                asset
                                        ).software.version_user == prefs(
                                        ).user:
                                            asset_version_list.append(asset)
                                            stats().add_version(asset)
Beispiel #2
0
def quick_pb():
    format = prefs().format
    project_path = prefs().project_path
    local_project_path = prefs().local_project_path
    start = cmds.playbackOptions(q=True, min=True)
    end = cmds.playbackOptions(q=True, max=True)

    if local_project_path and local_project_path != '':
        quickpb_path = utils.convert_local_path(
            os.path.join(os.path.dirname(cmds.file(q=True, sn=True)),
                         'quick_playblasts'), project_path, local_project_path)
        quick_file = utils.get_filename_without_override(
            os.path.join(quickpb_path, 'quick_playblast_0001.avi'))
        cmds.playblast(st=start,
                       et=end,
                       p=100,
                       f=quick_file,
                       wh=format,
                       qlt=70,
                       fp=4,
                       fmt='movie',
                       fo=1,
                       v=1)
        logger.info("Playblast saved as {}".format(quick_file))
    else:
        logger.warning('Please set a local project path in wizard before')
Beispiel #3
0
 def get_exported_asset(self):
     self.export_asset = copy.deepcopy(self.asset)
     self.export_asset.export_asset = prefs().asset(
         self.export_asset).export_root.default_export_asset
     self.export_asset.export_version = prefs().asset(
         self.export_asset).export.last_version
     file = prefs().asset(self.export_asset).export.full_file
     if os.path.isfile(file):
         return 1
     else:
         return 0
def get_asset_list():
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    references_list = prefs().asset(asset).software.references
    asset_list = []
    for namespace in list(references_list.keys()):
        imported_asset = asset_core.string_to_asset(
            references_list[namespace][defaults._asset_key_])
        folder = prefs().asset(imported_asset).export.version_folder
        from_software = prefs().asset(imported_asset).export.version_software
        imported_asset.software = from_software
        file = prefs().asset(imported_asset).export.file
        full_path = os.path.join(folder, file)
        asset_list.append([imported_asset, namespace, full_path])
    return asset_list
def duplicate_reference():
    sel = cmds.ls(sl=1, long=1)
    if len(sel) == 1:
        namespace = None
        relatives = cmds.listRelatives(sel[0], allDescendents=1)
        for relative in relatives:
            if cmds.referenceQuery(relative, isNodeReferenced=True):
                namespace = relative.split(':')[0]
                break
        if namespace:
            scene_asset = asset_core.string_to_asset(
                os.environ[defaults._asset_var_])
            references_list = prefs().asset(scene_asset).variant.references
            if namespace in references_list.keys():

                asset = asset_core.string_to_asset(
                    references_list[namespace][defaults._asset_key_])
                count = references(scene_asset).add_reference(asset, 1, 1)
                new_namespace = namespace.replace(
                    namespace.split('_')[-1], count)
                import_geo(new_namespace)

            else:
                logger.warning('This reference was not found in wizard')
    else:
        logger.warning('Please select only one asset')
Beispiel #6
0
def set_range():
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    range = prefs().asset(asset).name.range
    start = int(range[0])
    end = int(range[-1])
    Document().FirstFrame.set(start)
    Document().LastFrame.set(end)
Beispiel #7
0
def build_export_list(main_asset, namespace_list):

    references_list = prefs().asset(main_asset).variant.references

    for namespace in namespace_list:
        if namespace in references_list.keys():

            asset = references_list[namespace][defaults._asset_key_]
            locator = namespace + '_CTRL'
            world_infos = get_world_infos(locator)

            export_dic = dict()
            export_dic[namespace] = dict()
            export_dic[namespace][defaults._asset_key_] = asset
            export_dic[namespace][defaults._wsd_pos_] = world_infos[0]
            export_dic[namespace][defaults._wsd_rot_] = world_infos[1]
            export_dic[namespace][defaults._wsd_scale_] = world_infos[2]

            logger.info(export_dic)

            file = main_asset.export('{}-{}'.format(main_asset.name,
                                                    main_asset.variant))
            logger.info(file)
            wsd(file, export_dic).write_sd()
            wall.wall().publish_event(main_asset)

        else:
            logger.warning('Ignoring {}, not in references'.format(namespace))
Beispiel #8
0
def get_publish_stats():
    all_events = wall().get_all_keys()
    events_dic = wall().open_wall_file()

    stages_list = list()

    for event in all_events:
        if events_dic[event][defaults._creation_user_key_] == prefs(
        ).user and events_dic[event][
                defaults._wall_id_key_] == defaults._wall_publish_event_:
            asset_string = events_dic[event][defaults._asset_key_]
            asset = asset_core.string_to_asset(asset_string)
            if asset.stage and asset.stage != 'None':
                stages_list.append(asset.stage)

    design_pubs = stages_list.count(defaults._design_)
    geo_pubs = stages_list.count(defaults._geo_)
    rig_pubs = stages_list.count(defaults._rig_)
    texturing_pubs = stages_list.count(defaults._texturing_)
    hair_pubs = stages_list.count(defaults._hair_)
    shading_pubs = stages_list.count(defaults._shading_)
    return [
        design_pubs, geo_pubs, rig_pubs, texturing_pubs, hair_pubs,
        shading_pubs
    ]
Beispiel #9
0
def save():
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    asset.version = prefs().asset(asset).software.get_new_version()
    Document().save(asset.file)
    string_asset = utils.asset_to_string(asset)
    os.environ[defaults._asset_var_] = string_asset
    send_signal.save_request_signal(asset.file, string_asset)
Beispiel #10
0
def hide_ref():

    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    references_list = prefs().asset(asset).software.references
    selection = cmds.ls(sl=1)

    namespaces_list = []

    for sel in selection:
        if not cmds.referenceQuery(sel, isNodeReferenced=True):
            sel = cmds.listRelatives(sel)[1]

        if cmds.referenceQuery(sel, isNodeReferenced=True):
            namespace = sel.split(':')[0]
            if namespace not in namespaces_list:
                namespaces_list.append([namespace, sel])

    for namespace in namespaces_list:
        if namespace[0] in references_list.keys():
            asset = asset_core.string_to_asset(
                references_list[namespace[0]][defaults._asset_key_])
            file = cmds.referenceQuery(namespace[1], filename=True)
            cmds.file(file, unloadReference=True)

            hide_locator(namespace[0])
Beispiel #11
0
 def get_grooming_asset(self):
     self.grooming_asset = copy.deepcopy(self.rig_asset)
     self.grooming_asset.stage = defaults._hair_
     presence = None
     if checker.check_stage_existence(self.grooming_asset):
         self.grooming_asset.variant = self.rig_asset.variant
         if not checker.check_variant_existence(self.grooming_asset):
             self.grooming_asset.variant = prefs().asset(
                 self.grooming_asset).stage.default_variant
         if checker.check_variant_existence(self.grooming_asset):
             self.grooming_asset.export_asset = prefs().asset(
                 self.grooming_asset).export_root.default_export_asset
             if self.grooming_asset.export_asset:
                 self.grooming_asset.export_version = prefs().asset(
                     self.grooming_asset).export.last_version
                 presence = 1
     return presence
Beispiel #12
0
    def __init__(self, string_asset, file, temp_dir, frange, refresh_assets=0):

        self.asset = asset_core.string_to_asset(string_asset)
        self.file = file
        self.range = frange
        self.format = prefs().format
        self.temp_dir = temp_dir
        self.refresh_assets = refresh_assets
Beispiel #13
0
 def __init__(self, string_asset, file, nspace_list, frange, comment = None, set_done = 1, refresh_assets = 0):
     self.asset = asset_core.string_to_asset(string_asset)
     self.file = file
     self.nspace_list = nspace_list
     self.range = frange
     self.references_list = prefs().asset(self.asset).software.references
     self.comment = comment
     self.set_done = set_done
     self.camera = None
     self.refresh_assets = refresh_assets
Beispiel #14
0
def switch_proxy(proxy=1):

    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    references_list = prefs().asset(asset).software.references

    selection = cmds.ls(sl=1, long=1)

    namespaces_list = []

    for sel in selection:

        if not cmds.referenceQuery(sel, isNodeReferenced=True):
            sel = cmds.listRelatives(sel)[1]

        if cmds.referenceQuery(sel, isNodeReferenced=True):
            namespace = sel.split(':')[0]
            if namespace not in namespaces_list:
                namespaces_list.append([namespace, sel])

    for namespace in namespaces_list:
        if namespace[0] in references_list.keys():
            asset = asset_core.string_to_asset(
                references_list[namespace[0]][defaults._asset_key_])
            from_software = prefs().asset(asset).export.version_software
            asset.software = software
            if proxy:
                file = prefs().asset(asset).export.full_proxy
            else:
                file = prefs().asset(asset).export.full_file
            ref_node = cmds.referenceQuery(namespace[1], referenceNode=True)
            nodes = cmds.file(file, loadReference=ref_node, returnNewNodes=1)
            if cmds.objectType(nodes[0]) == 'reference':
                nodes.pop(0)
            grp = nodes[0]
            if nodes[0].endswith('GRP'):
                nodes.pop(0)
            for node in nodes:
                lock_node(node)
            if grp.endswith('GRP'):
                create_set_locator(grp, 1)

    cmds.select(selection, replace=1)
Beispiel #15
0
def asset_to_id(asset):
    id = (prefs().project_name).upper()
    id += asset.domain.upper()[0]

    if asset.variant:
        id += asset.category.upper()[:2]
        id += asset.name.upper()
        id += asset.stage.upper()[:2]
        id += asset.variant.upper()

    return id
Beispiel #16
0
def set_format(half=None):
    format = prefs().format

    if not half:
        width = format[0]
        height = format[1]
    else:
        width = int(format[0]) / 2
        height = int(format[1]) / 2

    Document().ProjectWidth.set(width)
    Document().ProjectHeight.set(height)
    Document().ProjectAspectRatio.set(1)
Beispiel #17
0
    def match_geos(self):
        match = None

        rig_references = prefs().asset(self.rig_asset).software.references
        rig_geo_asset = None
        for reference in rig_references.keys():
            asset = asset_core.string_to_asset(
                rig_references[reference][defaults._asset_key_])
            logger.info(asset.variant)
            logger.info(self.rig_asset.variant)
            if asset.stage == defaults._geo_ and asset.name == self.rig_asset.name:
                rig_geo_asset = asset
                break
        groom_references = prefs().asset(
            self.grooming_asset).software.references
        grooming_geo_asset = None
        for reference in groom_references.keys():
            asset = asset_core.string_to_asset(
                groom_references[reference][defaults._asset_key_])
            if asset.stage == defaults._geo_ and asset.name == self.grooming_asset.name:
                grooming_geo_asset = asset
                self.groom_geo_namespace = reference
                break
        if rig_geo_asset:
            if grooming_geo_asset:
                if rig_geo_asset.export_version == grooming_geo_asset.export_version:
                    match = 1
                else:
                    logger.warning(
                        "The geo imported in rig and the geo imported in grooming doesn't matchs"
                    )
            else:
                logger.warning("No geo imported in the grooming scene")
        else:
            logger.warning("No geo imported in the rig scene")

        return match
Beispiel #18
0
def show_stats():
    all_events = wall().get_all_keys()
    events_dic = wall().open_wall_file()

    stages_list = list()

    for event in all_events:
        if events_dic[event][defaults._creation_user_key_] == prefs(
        ).user and events_dic[event][
                defaults._wall_id_key_] == defaults._wall_publish_event_:
            asset_string = events_dic[event][defaults._asset_key_]
            asset = asset_core.string_to_asset(asset_string)
            if asset.stage and asset.stage != 'None':
                stages_list.append(asset.stage)

    all_versions = get_all_versions() + len(stages_list)
    versions_dic = stats().get_versions()

    design_occu = stages_list.count(defaults._design_)
    design_percent = (
        (design_occu + versions_dic[defaults._design_]) / all_versions) * 100
    geo_occu = stages_list.count(defaults._geo_)
    geo_percent = (
        (geo_occu + versions_dic[defaults._geo_]) / all_versions) * 100
    rig_occu = stages_list.count(defaults._rig_)
    rig_percent = (
        (rig_occu + versions_dic[defaults._rig_]) / all_versions) * 100
    hair_occu = stages_list.count(defaults._hair_)
    hair_percent = (
        (hair_occu + versions_dic[defaults._hair_]) / all_versions) * 100
    texturing_occu = stages_list.count(defaults._texturing_)
    texturing_percent = (
        (texturing_occu + versions_dic[defaults._texturing_]) /
        all_versions) * 100
    shading_occu = stages_list.count(defaults._shading_)
    shading_percent = (
        (shading_occu + versions_dic[defaults._shading_]) / all_versions) * 100

    return [
        design_percent, geo_percent, rig_percent, hair_percent,
        texturing_percent, shading_percent
    ]
Beispiel #19
0
    def create_new_scene(self):
        stage_exists = 0
        variant_exists = 0
        self.cfx_asset = copy.deepcopy(self.asset)
        self.cfx_asset.stage = defaults._cfx_
        self.cfx_asset.variant = 'auto_hair'
        if not checker.check_stage_existence(self.cfx_asset):
            self.cfx_asset.variant = None
            self.cfx_asset.software = None
            self.cfx_asset.version = None
            self.cfx_asset.export_asset = None
            self.cfx_asset.export_version = None
            if self.cfx_asset.create():
                stage_exists = 1
        else:
            stage_exists = 1

        self.cfx_asset.variant = 'auto_hair'
        if not checker.check_variant_existence(self.cfx_asset):
            logger.info('LOL')
            self.cfx_asset.software = None
            self.cfx_asset.version = None
            self.cfx_asset.export_asset = None
            self.cfx_asset.export_version = None
            if self.cfx_asset.create():
                variant_exists = 1
        else:
            variant_exists = 1

        if variant_exists and stage_exists:
            prefs().asset(
                self.cfx_asset).stage.set_default_variant('auto_hair')
            self.cfx_asset.software = prefs().asset(
                self.cfx_asset).variant.default_software
            self.cfx_asset.version = prefs().asset(
                self.cfx_asset).software.get_new_version()
            prefs().asset(self.cfx_asset).software.new_version(
                self.cfx_asset.version)
            self.cfx_scene = self.cfx_asset.file
        return (variant_exists * stage_exists)
Beispiel #20
0
from wizard.vars import defaults
from wizard.prefs.main import prefs
import os
from wizard.tools import log

logger = log.pipe_log(__name__)
prefs = prefs()

# Softwares commands
_executable_key_ = '[executable]'
_file_key_ = '[file]'
_script_key_ = '[startup_script]'
_reference_key_ = '[reference]'

_default_cmd_ = '"{}" "{}"'.format(_executable_key_, _file_key_)

_maya_cmd_ = '"{}" -file "{}" -script "{}"'.format(_executable_key_,
                                                   _file_key_, _script_key_)

_painter_cmd_ = '"{}" --mesh "{}" --split-by-udim "{}"'.format(
    _executable_key_, _reference_key_, _file_key_)

_guerilla_cmd_ = '''"{}" "{}" --pycmd "execfile('{}')"'''.format(
    _executable_key_, _file_key_, _script_key_)

_nuke_cmd_ = '"{}" --nukex "{}"'.format(_executable_key_, _file_key_)

_blender_cmd_ = '"{}" "{}" --python "{}"'.format(_executable_key_, _file_key_,
                                                 _script_key_)

_houdini_cmd_ = '"{}" "{}" waitforui "{}" '.format(_executable_key_,
Beispiel #21
0
 def __init__(self, main_ui):
     super(wallThread, self).__init__(main_ui)
     self.main_ui = main_ui
     self.prefs = prefs()
Beispiel #22
0
# Import wizard core libraries
from wizard.vars import defaults
from wizard.tools import log
from wizard.prefs.main import prefs
from wizard.prefs.stats import stats
from wizard.asset.tickets import tickets
from wizard.signal import send_signal
from wizard.tools import utility as utils

# Import wizard widgets
import wall_widget
import tickets_widget

# Init the main logger and prefs module
logger = log.pipe_log(__name__)
pref = prefs()

class Main(QtWidgets.QWidget):

    def __init__(self):
        super(Main, self).__init__()
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.init_icons()
        self.refresh_widget()
        self.connect_functions()

    def init_icons(self):
        self.ui.level_label.setPixmap(QtGui.QPixmap(defaults._lvl_icon_).scaled(16, 16, QtCore.Qt.KeepAspectRatio,
                                                                                QtCore.Qt.SmoothTransformation))
        self.ui.xp_label.setPixmap(
Beispiel #23
0
    def __init__(self):

        # Create the pyqt5 application
        os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"

        self.app = QtWidgets.QApplication(sys.argv)
        self.app.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
        #self.app.setStyle(QtWidgets.QStyleFactory.create("Fusion"))

        # Add the default wizard icon
        self.app.setWindowIcon(QtGui.QIcon(defaults._wizard_ico_))

        # Call the introduction widget
        # This widget is used to help the users in the using of Wizard
        self.ui_welcome = ui_welcome.Main()

        # Define the "run" variable
        # it will permit to block the process in a case of exception
        run = 1

        # Check if we need this widget before launching wizard main ui
        # Needed if no user is logged
        # no project is logged
        # or no server is launched
        if self.ui_welcome.need:

            # Check if the widget call was successful
            if not build.launch_dialog_as_child_frameless_trans(
                    self.ui_welcome):

                # If not stop the process
                run = 0

        # If the variable "run" is not 0 or None, continue the process
        if run:

            run = 0
            '''
            try:
                new_version = version.check_version().check_version()
            except:
            '''
            new_version = None

            if new_version and prefs().show_new_version:
                self.dialog_new_version = dialog_new_version.Main(new_version)
                if build.launch_dialog_as_child(self.dialog_new_version):
                    pass
                else:
                    run = 1
            else:
                run = 1

            if run:
                # Call the loading ui
                self.ui_load = ui_load.Main()
                # Launch the loading ui with the module "gui.build"
                build.launch_normal_as_child_frameless_no_transparent(
                    self.ui_load)
                # When the ui is showed, start the wizard introduction gif
                #self.ui_load.start_gif()
                # Wait for the wizard introduction gif to end
                #while not self.ui_load.go :
                # Refresh the ui while the wizard gif is running
                QApplication.processEvents()
                self.prefs = prefs()
                # Fake some loadings
                # Need to remove that
                self.ui_load.ui.loading_user_label.setText('User : {}'.format(
                    self.prefs.user))
                self.ui_load.ui.loading_project_label.setText(
                    'Project : {}'.format(self.prefs.project_name))
                self.update_loading_infos('Reading project...', 65)
                # Call the main ui but don't launch it - This function is the longest to run
                self.ui_main = ui_main.Main()
                self.update_loading_infos('Launching main ui...', 85)
                self.update_loading_infos('Launching main ui...', 90)
                self.update_loading_infos('Launching main ui...', 100)
                # Close the loading ui
                self.ui_load.close()
                # Call the desktop shutter and give it the main ui object
                shutter = prefs.shutter
                if shutter:
                    self.wizard_desktop = ui_wizard_desktop.wizard_desktop(
                        self.ui_main)
                # Show the main ui with the "build" module (from wizard)
                build.launch_stray_as_child(
                    self.ui_main,
                    self.app,
                    title=f'Wizard - Project : {self.prefs.project_name}')

                # Refresh the main ui
                self.ui_main.asset_item_changed()
                # Show the wizard desktop tray icon with the "build" module ( from wizard )
                if shutter:
                    build.launch_wizard_desktop(self.wizard_desktop)
Beispiel #24
0
def import_cfx(reload=0):

    asset_list = get_asset_list()
    grooming_GRP = add_GRP('CFX')

    for imported_asset in asset_list:

        fur_ext = prefs().custom_pub_ext_dic[defaults._cfx_][defaults._maya_]

        if fur_ext == 'fur':
            if imported_asset[0].stage == defaults._cfx_:

                nodes_list = []

                folder = os.path.split(imported_asset[2])[0]
                for file in os.listdir(folder):
                    if file.endswith('.fur'):
                        file = file.replace(
                            file.split('.')[-2] + '.fur', '%04d.fur')
                        node_tuple = [
                            file.split('.')[-3],
                            os.path.join(folder, file)
                        ]
                        if node_tuple not in nodes_list:
                            nodes_list.append(node_tuple)

                if imported_asset[1] not in get_all_nodes() and not reload:
                    for node_tuple in nodes_list:
                        with Modifier() as mod:

                            nspace_GRP = add_GRP(imported_asset[1],
                                                 grooming_GRP)

                            node_name = '{}:{}'.format(imported_asset[1],
                                                       node_tuple[0])

                            yeti_node = mod.createnode(node_name, "Yeti",
                                                       nspace_GRP)
                            yeti_node.File.set(node_tuple[1])
                            yeti_node.HierarchyMode.set(2)
                            yeti_node.Membership.set(node_tuple[0])

                elif imported_asset[1] in get_all_nodes() and reload:
                    for node_tuple in nodes_list:

                        nspace_GRP = add_GRP(imported_asset[1], grooming_GRP)

                        node_name = '{}:{}'.format(imported_asset[1],
                                                   node_tuple[0])

                        yeti_node = get_node_from_name(node_name)
                        yeti_node.File.set(node_tuple[1])

        if fur_ext == "abc":
            if imported_asset[0].stage == defaults._cfx_:

                folder = os.path.split(imported_asset[2])[0]
                file = os.path.join(folder, os.listdir(folder)[0])
                hair_tag = file.split('.')[-3]

                if imported_asset[1] not in get_all_nodes() and not reload:
                    with Modifier() as mod:

                        refNode, topNodes = mod.createref(
                            imported_asset[1], file, grooming_GRP)
                        refNode.Membership.set(hair_tag)
                        refNode.Membership.set(hair_tag)

                elif imported_asset[1] in get_all_nodes() and reload:
                    refNode = get_node_from_name(imported_asset[1])
                    refNode.ReferenceFileName.set(file)
Beispiel #25
0
def set_frame_rate():
    frame_rate = prefs().frame_rate
    Document().Preferences.FrameRate.set(frame_rate)
Beispiel #26
0
 def create_folder(self):
     shared_folder = os.path.join(prefs().project_path,
                                  defaults._shared_folder_)
     if not os.path.isdir(shared_folder):
         os.mkdir(shared_folder)
     self.shared_folder = shared_folder