示例#1
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])
示例#2
0
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')
示例#3
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
示例#4
0
    def auto_hair(self):

        for nspace in self.nspace_list:

            self.export_anim(nspace)

            self.rig_asset = asset_core.string_to_asset(
                self.references_dic[nspace][defaults._asset_key_])

            if self.get_grooming_asset():

                if self.match_geos():
                    if self.create_new_scene():
                        if self.get_exported_asset():
                            self.add_anim_reference()
                            self.add_grooming_reference()
                            self.build_scene()
                            self.blendshape_shapes()
                            self.export_hair()

                            if self.set_done:
                                print('status:Done !')

            else:
                logger.warning(
                    "No {} publish found for this asset : {}-{}".format(
                        defaults._hair_, self.rig_asset.category,
                        self.rig_asset.name))
示例#5
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)
示例#6
0
def tagGuerillaAuto(*arg):
    selectionGuerilla_List = pm.ls(sl=1)
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])

    if selectionGuerilla_List:
        for mesh in selectionGuerilla_List:
            if pm.attributeQuery('GuerillaTags', node=mesh, exists=1) == 0:
                pm.addAttr(mesh, ln="GuerillaTags", dt="string")

            currentAttr = mesh.name() + '.GuerillaTags'
            currentTag = pm.getAttr(currentAttr)

            tags_list = []
            if currentTag:
                tags_list = currentTag.split(',')

            if mesh.name() not in tags_list:
                tags_list.append(mesh.name())
            if asset.category not in tags_list:
                tags_list.append(asset.category)
            if asset.name not in tags_list:
                tags_list.append(asset.name)
            if asset.variant not in tags_list:
                tags_list.append(asset.variant)
            name_variant = '{}_{}'.format(asset.name, asset.variant)
            if name_variant not in tags_list:
                tags_list.append(name_variant)

            attrs = (',').join(tags_list)

            pm.setAttr(mesh + '.GuerillaTags', attrs, type="string")

    else:
        pm.warning('Your selection is empty')
示例#7
0
    def save(self, signal_dic):
        file = signal_dic[defaults._signal_file_key_]
        asset = asset_core.string_to_asset(
            signal_dic[defaults._signal_asset_key_])
        filename = os.path.basename(file)
        filename = filename.split('.')[0]
        if filename == folder(asset).work_name_template:
            version = folder(asset).version_from_file(file)
            if version.isdigit():
                asset.version = prefs.asset(asset).software.new_version(
                    version=version)
                time.sleep(1)
                try:
                    im_file = prefs.asset(asset).software.image
                    screen_tools.screen_shot_current_screen(im_file)
                except:
                    logger.critical(str(traceback.format_exc()))

                # Try refreshing the ui
                try:
                    send_signal.refresh_signal()
                    logger.info('{} saved ({})'.format(file, asset.software))
                    send_signal.save_signal()
                    stats().add_xp(2)
                    stats().add_version(asset)
                except:
                    pass
示例#8
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)
示例#9
0
    def export(self):
        items_list = self.ui.export_ma_assets_listWidget.selectedItems()
        if self.out_range:

            nspace_list = []
            cam_nspace_list = []
            for item in items_list:
                asset_item = asset_core.string_to_asset(
                    self.references[item.text()][defaults._asset_key_])
                if asset_item.stage == defaults._cam_rig_:
                    cam_nspace_list.append(item.text())
                elif asset_item.stage == defaults._rig_:
                    nspace_list.append(item.text())

            self.asset.version = prefs.asset(self.asset).software.last_version
            auto_hair = self.ui.export_auto_hair_checkBox.isChecked()
            refresh_assets = self.ui.export_m_refresh_assets_checkBox.isChecked(
            )

            batch_export.sequence(self.asset, nspace_list, cam_nspace_list,
                                  self.out_range, refresh_assets, auto_hair)

            self.hide()

        else:
            logger.warning("Please enter a valid frame range")
示例#10
0
def export():
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    stage = asset.stage
    category = asset.category
    if stage == defaults._geo_:
        if asset.category == defaults._set_dress_:
            export_set_dress()
        elif asset.category == defaults._sets_:
            export_sets()
        else:
            export_geo()
    elif stage == defaults._rig_:
        export_rig()
    elif stage == defaults._autorig_:
        export_autoRig()
    elif stage == defaults._cam_rig_:
        export_camRig()
    elif stage == defaults._hair_:
        export_hair()
    elif stage == defaults._layout_:
        export_layout()
    elif stage == defaults._cyclo_:
        export_cyclo()
    else:
        logger.warning('Unknown stage...')
示例#11
0
def batch_export(refresh_asset, out_range):
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])

    print('current_task:exporting {}-{}-{}...'.format(asset.category,
                                                      asset.name, asset.stage))
    print('status:starting...')
    print('percent:0')
    sys.stdout.flush()

    file = asset.file
    print('current_task:openning file {}'.format(file))
    sys.stdout.flush()

    hou.hipFile.load(file)
    reference_asset.import_all()
    if refresh_asset:
        reference_asset.refresh_all()

    print('percent:20')
    sys.stdout.flush()

    print('current_task:exporting asset')
    print('percent:25')
    sys.stdout.flush()
    plugin.export(batch=1, frange=out_range)

    print('percent:100')
    print('status:Done !')
    sys.stdout.flush()
示例#12
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
    ]
示例#13
0
def save():
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    asset.version = prefs.asset(asset).software.get_new_version()
    hou.hipFile.save(file_name=asset.file)
    string_asset = asset_core.asset_to_string(asset)
    os.environ[defaults._asset_var_] = string_asset
    send_signal.save_request_signal(asset.file, string_asset)
示例#14
0
def export_geo():
    '''Takes 'geo_GRP' and export all meshes.'''
    if sanity(defaults._stage_export_grp_dic_[defaults._geo_]):
        save()
        geo_GRP = bpy.data.collections[defaults._stage_export_grp_dic_[
            defaults._geo_]]
        # unselect all
        bpy.ops.object.select_all(action='DESELECT')
        # select geo_GRP to convert collection to Maya grp (Empty type objects)
        geo_GRP = tools.replace_blender_collection_by_maya_grp(geo_GRP)
        # add guerilla tags to mesh object - NOT SUPPORTED BY BLENDER YET

        for mesh in tools.list_objects(geo_GRP):
            # if it's a mesh or an empty (= Maya groups) add it to selection
            if mesh.type == 'MESH' or mesh.type == 'PLAIN_AXES':
                # auto_tag.tagGuerillaAuto()
                mesh.select_set(True)

        asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
        file = asset.export("{}_{}".format(asset.name, asset.variant),
                            from_asset=asset)  ### < J'ai rajouté ça
        # time_range = prefs.asset(asset).name.range
        time_range = [1, 1]
        export_abc(time_range, file, selected=True)
        wall().publish_event(asset)
        logger.info('Geo exported.')
        # reload Blender file to retrieve collection hierarchy
        bpy.ops.wm.open_mainfile(filepath=asset.file)
示例#15
0
def export_maps():

    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    file = asset.export('{}_{}'.format(asset.name, asset.variant))
    filename = os.path.splitext(os.path.split(file)[-1])[0]
    ext = os.path.splitext(os.path.split(file)[-1])[-1].split('.')[-1]

    export_config.json_config['exportPath'] = os.path.split(file)[0]
    export_config.json_config["exportPresets"][0]['maps'][0]['fileName'] = "{}_baseColor.$textureSet".format(filename)
    export_config.json_config["exportPresets"][0]['maps'][1]['fileName'] = "{}_roughness.$textureSet".format(filename)
    export_config.json_config["exportPresets"][0]['maps'][2]['fileName'] = "{}_metallic.$textureSet".format(filename)
    export_config.json_config["exportPresets"][0]['maps'][3]['fileName'] = "{}_normal.$textureSet".format(filename)
    export_config.json_config["exportPresets"][0]['maps'][4]['fileName'] = "{}_height.$textureSet".format(filename)
    export_config.json_config["exportPresets"][0]['maps'][5]['fileName'] = "{}_sss.$textureSet".format(filename)
    export_config.json_config['exportParameters'][0]['parameters']['fileFormat'] = ext

    export_list = []
    for set in substance_painter.textureset.all_texture_sets():
        set_name = set.name()
        dict = {}
        dict['rootPath'] = set_name
        export_list.append(dict)
    export_config.json_config['exportList']=export_list

    substance_painter.export.export_project_textures(export_config.json_config)
示例#16
0
def create_export_GRP():
    '''Create 'export_GRP' based on the asset current stage.'''
    stage = asset_core.string_to_asset(os.environ[defaults._asset_var_]).stage

    if stage == defaults._geo_:
        grp_name = 'geo_GRP'
    elif stage == defaults._rig_:
        grp_name = 'rig_GRP'

    # obj_list = bpy.context.selected_objects

    # create export_Grp collection if not exist
    if bpy.data.collections.get(grp_name) is None:
        grp_name_collection = bpy.data.collections.new(grp_name)
        bpy.context.scene.collection.children.link(grp_name_collection)
    # add selected object to new grp
    # for obj in obj_list:
    #     try:
    #         old_obj_collection = obj.users_collection
    #         bpy.data.collections[grp_name].objects.link(obj)
    #         for old_coll in old_obj_collection:
    #             old_coll.objects.unlink(obj)
    #     except:
    #         continue
    logger.info('{} created.'.format(grp_name))
示例#17
0
def create_set():

    #selection_list = cmds.ls(sl=1)
    stage = asset_core.string_to_asset(os.environ[defaults._asset_var_]).stage
    sets_name_list = []
    obj_list = cmds.ls(sl=True)

    if stage==defaults._rig_:
        rig_set_name = defaults._rig_export_set_
        rig_sets_name = defaults._rig_sets_
        sets_name_list.append(rig_set_name)
        sets_name_list.append(rig_sets_name)
    elif stage==defaults._hair_:
        yeti_set__name = defaults._yeti_export_set_
        sets_name_list.append(yeti_set__name)
        scalp_set_name = defaults._scalp_export_set_
        sets_name_list.append(scalp_set_name)
    elif stage==defaults._cam_rig_:
        camera_set_name = defaults._camrig_export_set_
        sets_name_list.append(camera_set_name)

    for set_name in sets_name_list:
        if not cmds.objExists(set_name):
            cmds.sets(n=set_name, empty=True)

        cmds.sets(clear=set_name)

    if cmds.objExists(set_name):
        for obj in obj_list:
            cmds.sets( obj, add=set_name )
示例#18
0
def export_abc(batch=None, prepare=None, frange=None):

    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])

    if not batch:
        abc_export_null = create_export_null_on_last_node('abc')
    else:
        abc_export_null = look_for_export_null('abc')

    if abc_export_null:

        wizard_exports_node = get_wizard_export_node()
        abc_object_merge_node = create_node_without_duplicate(
            'object_merge', 'abc_exports_object_merge', wizard_exports_node)

        abc_object_merge_node.parm('objpath1').set(abc_export_null.path())

        gtags_node = create_node_without_duplicate('attribcreate',
                                                   'GuerillaTags',
                                                   wizard_exports_node)
        gtags_node.parm('name1').set('GuerillaTags')
        gtags_node.parm('class1').set('detail')
        gtags_node.parm('type1').set('index')
        gtags_node.parm('string1').set('{}, {}, {}, {}, {}-{}-{}-{}'.format(
            asset.category, asset.name, asset.variant, asset.stage,
            asset.category, asset.name, asset.variant, asset.stage))

        gtags_node.setInput(0, abc_object_merge_node)

        rop_alembic_node = create_node_without_duplicate(
            'rop_alembic', 'exports_alembic', wizard_exports_node)
        rop_alembic_node.setInput(0, gtags_node)
        wizard_exports_node.layoutChildren()

        rop_alembic_node.parm("trange").set('normal')

        if frange:
            hou.playbar.setFrameRange(frange[0], frange[1])

        rop_alembic_node.parm("f1").setExpression('$FSTART')
        rop_alembic_node.parm("f2").setExpression('$FEND')

        rop_alembic_node.parm("motionBlur").set(1)
        rop_alembic_node.parm("shutter1").set(-0.2)
        rop_alembic_node.parm("shutter2").set(0.2)
        if batch:
            rop_alembic_node.parm('lpostframe').set("python")
            rop_alembic_node.parm('postframe').set(by_frame_script_to_file(80))

        if not prepare:
            export_file = asset.export("{}_{}".format(asset.name,
                                                      asset.variant),
                                       from_asset=asset)
            rop_alembic_node.parm("filename").set(export_file)
            rop_alembic_node.parm("execute").pressButton()
            wall.wall().publish_event(asset)

    else:
        logger.warning("No abc out node")
示例#19
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
示例#20
0
def export(batch=None, frange=None):
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    if asset.extension == "hipnc":
        export_hipfile()
    elif asset.extension == "abc":
        export_abc(batch=batch, frange=frange)
    elif asset.extension == "vdb":
        export_vdb(batch=batch, frange=frange)
示例#21
0
def export_hipfile():
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    export_file = asset.export("{}_{}".format(asset.name, asset.variant),
                               from_asset=asset)

    hou.hipFile.save()
    current_file = hou.hipFile.path()
    shutil.copyfile(current_file, export_file)
    wall.wall().publish_event(asset)
示例#22
0
def save():
    '''Save file in an incremental version.'''
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    asset.version = prefs.asset(asset).software.get_new_version()
    bpy.ops.wm.save_as_mainfile(filepath=asset.file)
    logger.info('File saved.')
    string_asset = utils.asset_to_string(asset)
    os.environ[defaults._asset_var_] = string_asset
    send_signal.save_request_signal(asset.file, string_asset)
示例#23
0
    def __init__(self):

        self.asset = asset_core.string_to_asset(
            os.environ[defaults._asset_var_])
        self.render_pass_list = get_all_render_passes()
        self.file_pattern = "$L_$n_$o.$05f.$x"
        self.depth = 'half'
        self.extension = 'exr'
        self.shot_range = prefs.asset(self.asset).name.range
示例#24
0
def init():
    cmds.loadPlugin('AbcImport.mll')
    shelf.shelf('Wizard')
    menu()
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    cmds.file(asset.file, o=True)
    reference_asset.import_all()
    scene_setup.set_f_range()
    scene_setup.setFormatToMaya()
示例#25
0
 def unlock_all(self):
     locks_list = prefs.locks
     for lock in locks_list:
         asset = asset_core.string_to_asset(lock)
         if prefs.asset(asset).software.get_lock:
             prefs.asset(asset).software.unlock()
         prefs.remove_lock(utils.short_asset_to_string(asset))
     self.locks = None
     self.setup_widget()
示例#26
0
def set_f_range():
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    f_range = prefs.asset(asset).name.range
    for n in nuke.allNodes('Read'):
        n['first'].setValue(f_range[0])
        n['last'].setValue(f_range[1])
        n['origfirst'].setValue(f_range[0])
        n['origlast'].setValue(f_range[1])
    nuke.knob("root.first_frame", str(f_range[0]))
    nuke.knob("root.last_frame", str(f_range[1]))
示例#27
0
def save():
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    asset.version = prefs.asset(asset).software.get_new_version()
    if os.path.isfile(asset.file):
        asset.version = str(int(asset.version) + 1).zfill(4)
    cmds.file(rename=asset.file)
    cmds.file(save=True, type='mayaAscii')
    string_asset = utils.asset_to_string(asset)
    os.environ[defaults._asset_var_] = string_asset
    send_signal.save_request_signal(asset.file, string_asset)
示例#28
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
示例#29
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)
示例#30
0
def set_f_range(preroll=0):
    asset = asset_core.string_to_asset(os.environ[defaults._asset_var_])
    f_range = prefs.asset(asset).name.range

    if preroll:
        preroll = prefs.asset(asset).name.preroll
        postroll = prefs.asset(asset).name.postroll
        f_range[0] = f_range[0] - preroll
        f_range[1] = f_range[1] + postroll

    hou.playbar.setFrameRange(f_range[0], f_range[1])