Пример #1
0
    def parse_path(self, path):
        """
        Parse paths and returns the tokens path is generated from
        :param path: str
        :return: list(str)
        """

        all_templates = artellapipe.NamesMgr().naming_lib.templates
        for template in all_templates:
            path_dict = artellapipe.NamesMgr().naming_lib.parse_template(
                template.name, path)
            if not path_dict:
                continue
            return path_dict
Пример #2
0
    def process(self, context):
        assert tpDcc.is_maya(
        ), 'Validate Proxy Mesh is only available in Maya!'

        from tpDcc.dccs.maya.core import node, api

        root_group_name = artellapipe.NamesMgr().solve_name('root_group')
        proxy_group_name = artellapipe.NamesMgr().solve_name('proxy_group')
        geo_group_name = artellapipe.NamesMgr().solve_name('geo_group')
        proxy_geo = artellapipe.NamesMgr().solve_name('proxy_geo')
        proxy_geo_parent = '{}|{}|{}'.format(root_group_name, proxy_group_name,
                                             geo_group_name)

        assert proxy_geo and tpDcc.Dcc.object_exists(
            proxy_geo
        ), 'Proxy geo "{}" does not exist in current scene!'.format(proxy_geo)
        assert proxy_geo_parent and tpDcc.Dcc.object_exists(
            proxy_geo_parent
        ), 'Proxy geo parent "{}" does not exists in current scene!'.format(
            proxy_geo_parent)

        proxy_prefix = proxy_geo.split('_')[0]
        proxy_geos = tpDcc.Dcc.list_nodes('{}_*'.format(proxy_prefix),
                                          node_type='transform') or list()
        assert len(
            proxy_geos
        ) == 1, 'Invalid number ({}) of proxy geometries found in current scene: {}'.format(
            len(proxy_geos), proxy_geos)
        proxy_geo = proxy_geos[0]
        proxy_geo_shapes = tpDcc.Dcc.list_shapes(proxy_geo)
        assert proxy_geo_shapes, 'No sahpes found in proxy geo geometry!'

        # We check that all vertex colors have
        vertices_without_vertex_colors = dict()
        for proxy_shape in proxy_geo_shapes:
            proxy_shape_node = node.get_mobject(proxy_shape)
            proxy_shape_vtx_it = api.IterateVertices(proxy_shape_node)
            proxy_shape_vertex_colors = proxy_shape_vtx_it.get_vertex_colors(
                skip_vertices_without_vertex_colors=False)
            for vtx_id, vtx_color in proxy_shape_vertex_colors.items():
                if vtx_color:
                    continue
                if proxy_shape not in vertices_without_vertex_colors:
                    vertices_without_vertex_colors[proxy_shape] = list()
                vertices_without_vertex_colors[proxy_shape].append(vtx_id)
        if vertices_without_vertex_colors:
            context.data[
                'vertices_without_vertex_colors'] = vertices_without_vertex_colors
        assert not vertices_without_vertex_colors, 'Some vertices of the proxy shapes have no vertex color ' \
                                                   'applied to them: {}!'.format(vertices_without_vertex_colors)
Пример #3
0
    def ui(self):
        super(NameManager, self).ui()

        self._name_widget = NameWidget(
            naming_lib=artellapipe.NamesMgr().naming_lib,
            project=self._project)
        self.main_layout.addWidget(self._name_widget)
Пример #4
0
    def get_template(self, template_name):
        """
        Returns path template with the given name
        :param template_name: str
        :return: Template
        """

        template = artellapipe.NamesMgr().naming_lib.get_template(
            template_name)
        if not template:
            LOGGER.warning(
                'No Template found with name: "{}"'.format(template_name))

        return template
Пример #5
0
    def process(self, context):

        import maya.cmds as cmds

        project = None
        for name, value in artellapipe.__dict__.items():
            if name == 'project':
                project = value
                break

        assert project, 'Project not found'

        proxy_geo = artellapipe.NamesMgr().solve_name('proxy_geo')
        if proxy_geo and cmds.objExists(proxy_geo):
            node_name = proxy_geo.split('|')[-1].split(':')[-1]
            instance = context.create_instance(node_name, project=project)
            instance.data['icon'] = 'cube'
            instance.data['node'] = proxy_geo
            instance.data['family'] = 'proxy'
Пример #6
0
    def process(self, instance):
        assert tp.is_maya(
        ), 'Validate Proxy Mesh Nomenclature is only available in Maya!'

        node = instance.data.get('node', None)
        assert tp.Dcc.object_exists(
            node
        ), 'No valid proxy mesh node found in current instance: {}'.format(
            instance)

        name_lib = artellapipe.NamesMgr().naming_lib
        name_lib.set_active_rule('proxy_geo')

        parsed_name = name_lib.parse(node)

        valid_name = True
        for k, v in parsed_name.items():
            if v is None:
                valid_name = False
                break

        assert valid_name, 'Proxy Mesh Node is not valid!'
Пример #7
0
    def process(self, instance):
        assert tp.is_maya(
        ), 'Check Modeling Nomenclature is only available in Maya!'

        node = instance.data.get('node', None)
        assert tp.Dcc.object_exists(
            node), 'No valid node found in current instance: {}'.format(
                instance)

        nodes_to_check = self._nodes_to_check(node)
        assert nodes_to_check, 'No Nodes to check found!'

        invalid_nodes = list()

        for node in nodes_to_check:
            valid_name = artellapipe.NamesMgr().check_node_name(node)
            if not valid_name:
                invalid_nodes.append(node)

        instance.data['invalid_nodes'] = invalid_nodes

        assert not invalid_nodes, 'Nodes with invalid names found: {}'.format(
            invalid_nodes)
Пример #8
0
    def process(self, context, plugin):
        if not tpDcc.is_maya():
            self.log.warning('Setup Hierarchy Action is only available in Maya!')
            return False

        from tpDcc.dccs.maya.core import scene

        # Make sure that root group exists
        root_group_name = artellapipe.NamesMgr().solve_name('root_group')
        create_root = context.data.get('create_root', False)
        if create_root:
            tpDcc.Dcc.create_empty_group(root_group_name)
        assert tpDcc.Dcc.object_exists(root_group_name), 'Root group node does not exists in current scene!'

        geo_group_name = artellapipe.NamesMgr().solve_name('geo_group')
        if not geo_group_name.startswith('|'):
            geo_group_name = '|{}'.format(geo_group_name)

        # Make sure that high group exists
        high_group_name = artellapipe.NamesMgr().solve_name('high_group')
        create_high = context.data.get('create_high', False)
        parent_high = context.data.get('parent_high', False)
        create_geo_high = context.data.get('create_high_geo')
        if create_high:
            tpDcc.Dcc.create_empty_group(high_group_name)
            parent_high = True
            create_geo_high = True
        assert tpDcc.Dcc.object_exists(high_group_name), 'High group node does not exists in current scene!'
        if parent_high:
            if create_geo_high:
                tpDcc.Dcc.create_empty_group(geo_group_name, parent=high_group_name)
            tpDcc.Dcc.set_parent(high_group_name, root_group_name)

        # Make sure that proxy group exists
        proxy_group_name = artellapipe.NamesMgr().solve_name('proxy_group')
        create_proxy = context.data.get('create_proxy', False)
        parent_proxy = context.data.get('parent_proxy', False)
        create_geo_proxy = context.data.get('create_proxy_geo')
        if create_proxy:
            tpDcc.Dcc.create_empty_group(proxy_group_name)
            parent_proxy = True
            create_geo_proxy = True
        assert tpDcc.Dcc.object_exists(proxy_group_name), 'Proxy group node does not exists in current scene!'
        if parent_proxy:
            if create_geo_proxy:
                tpDcc.Dcc.create_empty_group(geo_group_name, parent=proxy_group_name)
            tpDcc.Dcc.set_parent(proxy_group_name, root_group_name)

        # Make sure that proxy geometry is in the scene and parented properly
        check_proxy_geo = context.data.get('check_proxy_geo', False)
        if check_proxy_geo:
            proxy_geo_parent = '{}|{}|{}'.format(root_group_name, proxy_group_name, geo_group_name)
            proxy_geo = artellapipe.NamesMgr().solve_name('proxy_geo')
            assert proxy_geo and tpDcc.Dcc.object_exists(
                proxy_geo), 'Proxy geometry "{}" not found in scene!'.format(proxy_geo)
            assert tpDcc.Dcc.object_exists(
                proxy_geo_parent), 'Proxy geo parent "{}" does not exists in scene!'.format(proxy_geo_parent)
            if tpDcc.Dcc.node_parent(proxy_geo) != proxy_geo_parent:
                tpDcc.Dcc.set_parent(proxy_geo, proxy_geo_parent)

        # Parent the rest of nodes located in root to high group
        top_transforms = scene.get_top_dag_nodes(exclude_cameras=True)
        if len(top_transforms) > 1:
            high_geo_parent = '{}|{}|{}'.format(root_group_name, high_group_name, geo_group_name)
            assert tpDcc.Dcc.object_exists(
                high_geo_parent), 'High geo parent "{}" does not exists in scene!'.format(high_geo_parent)
            for top_transform in top_transforms:
                if top_transform == root_group_name:
                    continue
                tpDcc.Dcc.set_parent(top_transform, high_geo_parent)
Пример #9
0
    def process(self, context):
        assert tpDcc.is_maya(), 'Validate Modeling Hierarchy is only available in Maya!'

        from tpDcc.dccs.maya.core import scene

        multiple_roots = False
        create_root = False
        create_high = False
        create_proxy = False
        parent_high = False
        parent_proxy = False
        create_high_geo = False
        create_proxy_geo = False
        check_proxy_geo = False

        top_transforms = scene.get_top_dag_nodes(exclude_cameras=True)
        if len(top_transforms) > 1:
            self.log.warning(
                'Multiple root nodes ({}) found in the scene: {}! Only should be 1 root node (root)'.format(
                    len(top_transforms), top_transforms))
            multiple_roots = True

        root_group_name = artellapipe.NamesMgr().solve_name('root_group')
        if not root_group_name.startswith('|'):
            root_group_name = '|{}'.format(root_group_name)
        if not tpDcc.Dcc.object_exists(root_group_name):
            self.log.warning('Root Group "{}" does not exists in current scene!'.format(root_group_name))
            create_root = True

        geo_group_name = artellapipe.NamesMgr().solve_name('geo_group')

        high_group_name = artellapipe.NamesMgr().solve_name('high_group')
        if not tpDcc.Dcc.object_exists(high_group_name):
            self.log.warning('High Group "{}" does not exists in current scene!'.format(root_group_name))
            create_high = True
        if not create_root and not create_high:
            parent = tpDcc.Dcc.node_parent(high_group_name)
            if parent != root_group_name:
                self.log.warning(
                    'High Group "{}" is not parented to root group "{}"!'.format(high_group_name, root_group_name))
                parent_high = True
        if not create_high:
            high_children = tpDcc.Dcc.list_children(high_group_name, full_path=False, all_hierarchy=False)
            if geo_group_name not in high_children:
                create_high_geo = True

        proxy_group_name = artellapipe.NamesMgr().solve_name('proxy_group')
        if not tpDcc.Dcc.object_exists(proxy_group_name):
            self.log.warning('Root Group "{}" does not exists in current scene!'.format(root_group_name))
            create_proxy = True
        if not create_root and not create_proxy:
            parent = tpDcc.Dcc.node_parent(high_group_name)
            if parent != root_group_name:
                self.log.warning(
                    'Proxy Group "{}" is not parented to root group "{}"!'.format(high_group_name, root_group_name))
                parent_proxy = True
        if not create_proxy:
            proxy_chlidren = tpDcc.Dcc.list_children(proxy_group_name, full_path=False, all_hierarchy=False)
            if geo_group_name not in proxy_chlidren:
                create_proxy_geo = True

        proxy_geo_parent = '{}|{}|{}'.format(root_group_name, proxy_group_name, geo_group_name)
        proxy_geo = artellapipe.NamesMgr().solve_name('proxy_geo')
        if not proxy_geo or not tpDcc.Dcc.object_exists(proxy_geo):
            check_proxy_geo = True
            self.log.warning('Proxy Geometry "{}" does not exists!'.format(proxy_geo))
        else:
            if tpDcc.Dcc.node_parent(proxy_geo) != proxy_geo_parent:
                self.log.warning('Proxy Geometry {} is not parented under "{}"'.format(proxy_geo, proxy_geo_parent))
                check_proxy_geo = True

        context.data['create_root'] = create_root
        context.data['create_high'] = create_high
        context.data['create_proxy'] = create_proxy
        context.data['parent_high'] = parent_high
        context.data['parent_proxy'] = parent_proxy
        context.data['create_high_geo'] = create_high_geo
        context.data['create_proxy_geo'] = create_proxy_geo
        context.data['check_proxy_geo'] = check_proxy_geo

        assert not create_root and not create_high and not create_proxy and not parent_high and not \
            parent_proxy and not create_high_geo and not create_proxy and not multiple_roots and not \
            check_proxy_geo, 'Hierarchy is not valid!'