Example #1
0
    def accept(self):

        # handles closing the dialog
        super(ImportDialog, self).accept()

        try:
            entity_classes = EntityRegistry().get_entity_classes(
                self.session.app_name)

            entity_class = None
            for ec in entity_classes:
                if ec.category == 'geom':
                    entity_class = ec
                    has_import_product = True
                else:
                    has_import_product = False

            if has_import_product:
                val = self.options.value.products[0]
                ec(self.sublist[val][0],
                   self.session).import_product(self.sublist[val][1],
                                                self.sublist[val][0])

        except ActionError as e:
            error_dialog = QtGui.QErrorMessage(self.parent())
            error_dialog.setWindowTitle('Import Product Failure')
            error_dialog.showMessage(
                "There was an error trying to import the product.")
Example #2
0
    def _query_categories(self):
        self._entity_categories = []

        entity_classes = EntityRegistry().get_entity_classes(
            self.session.app_name)

        for entity in entity_classes:
            if not entity.importable:
                continue

            self._entity_categories.append(entity.category)
Example #3
0
    def list_entities(self, categories=None):
        """List entities in the session.""" 

        entities = []
        entity_classes = EntityRegistry().get_entity_classes(
            self.__class__.app_name)
        for entity_class in entity_classes:
            entities.extend(entity_class.list(self))

        if categories:
            filtered = [e for e in entities if e.category in categories]
        else:
            filtered = entities

        return filtered
Example #4
0
    def __init__(self, session=None, parent=None):

        super(SubscriptionImportWizard, self).__init__(parent=parent)

        self.setModal(True)

        if not session:
            session = SessionRegistry().current()

        self._session = session

        logo_pixmap = QtGui.QPixmap(
            IconFactory().disk_path("icon:///images/icons/import_32x32.png"))

        self.setWindowTitle("Subscription Import")
        self.setPixmap(QtGui.QWizard.LogoPixmap, logo_pixmap)

        # get entity classes
        entity_classes = EntityRegistry().get_entity_classes(
            self.session.app_name)

        # map entity category to class
        self._category_lookup = {}
        for cls in entity_classes:
            self._category_lookup[cls.category] = cls

        selection_id = self.addPage(self.sub_selection_page)
        options_id = self.addPage(self.import_options_page)

        self.setOption(QtGui.QWizard.CancelButtonOnLeft, on=True)
        self.setButtonText(QtGui.QWizard.FinishButton, 'Import')

        self._subs_widget.itemSelectionChanged.connect(self._toggle_options)

        if not self._subs_widget.repr_items: 
            QtGui.QMessageBox.warning(self.parent(), "Import Warning",
                "<b>No subs available to Import</b>."
            )
            self.NO_SUBS = True
Example #5
0
        product_repr.area.set_permissions(0660)

        return [product_repr]

    # -------------------------------------------------------------------------
    def _fbx_export(self, options, product_desc, version_note):

        self.session.require_plugin('fbxmaya')

        file_ext = 'fbx'

        product_repr = self._create_product(product_desc, version_note,
                                            file_ext)
        product_repr_dir = product_repr.directory

        export_objs = self.get_export_objects()

        export_path = os.path.join(product_repr_dir, self.display_name)

        with self.session.selected(export_objs):
            self.session.mel.eval(
                'FBXExport -f "{path}" -s'.format(path=export_path))

        product_repr.area.set_permissions(0660)

        return [product_repr]


# -----------------------------------------------------------------------------
EntityRegistry().register('maya', GeomcacheEntity)
Example #6
0
                    attr='rman__riattr__displacementbound_coordinatesystem'))

            session.mel.eval(
                add_attr.format(sn=shader_name,
                                attr='rman__riattr__trace_displacements'))

            if connect:
                session.cmds.connectAttr(file_node + '.outColor.outColorR',
                                         shader_name + '.displacementScalar')

            session.cmds.setAttr(shader_name + '.displacementAmount', 1.0)

            session.cmds.setAttr(
                shader_name + ".rman__riattr__displacementbound_sphere", 1.0)

            session.mel.eval('rmanSetAttr {sn} {val} 0;'.format(
                sn=shader_name, val='enableDisplacement'))

        # UNKNOWN
        else:
            raise EntityError("Don't know how to process map type: " +
                              maps_type)

    # -------------------------------------------------------------------------
    def export(self, *args, **kwargs):
        raise EntityError("Maya maps export not implemented.")


# -----------------------------------------------------------------------------
EntityRegistry().register('maya', MapsEntity)
Example #7
0
                                geo = session.mari.geo.current()
                                geo_channel = geo.channel(channel_name)
                                adjustment_layer = \
                                    geo_channel.createAdjustmentLayer(
                                        layer_name, adjustment_key)
                                adjustment_layer.setVisibility(False)

                        # other layer types...

        # close and archive the new project
        project = session.mari.projects.current()
        uuid = project.uuid()
        project.save(force_save=True)
        project.close(confirm_if_modified=False)

        # archive
        mari_file = os.path.join(mari_dir, product_name + '.mra')
        session.mari.projects.archive(uuid, mari_file)
        os.chmod(mari_file, 0770)
        session.mari.projects.open(uuid)

    # -------------------------------------------------------------------------
    def export(self, *args, **kwargs):
        """Export this entity to a product."""

        raise EntityError("Mari geom export not supported.")


# -----------------------------------------------------------------------------
EntityRegistry().register('mari', GeomEntity)
Example #8
0
            if geo is None:
                raise EntityError("Please select an object to export a "
                                  "channel from for this entity.")

            export_channels = geo.channelList()

            if not export_channels:
                raise EntityError("There are no channels to export for "
                                  "this entity.")

            return export_channels

    # -------------------------------------------------------------------------
    @classmethod
    def get_resolution(cls, session, imgset):
        # this would be nice, but the issue is that mari patches
        # can have various sizes, so it cant be applied globally to a channel
        pass

    # -------------------------------------------------------------------------
    def get_export_objects(self):
        return self._get_export_channels()

    # -------------------------------------------------------------------------
    def _get_export_channels(self):
        return self.__class__.get_export_channels(self.session)


# -----------------------------------------------------------------------------
EntityRegistry().register('mari', MapsEntity)
Example #9
0
        if representation.type == 'abc':
            cls._abc_import(session, representation, *args, **kwargs)
        else:
            raise EntityError(
                "Unknown type for {cat} import: {typ}".format(
                    cat=cls.category, typ=representation.type))

    # -------------------------------------------------------------------------
    @classmethod
    def _abc_import(cls, session, representation, *args, **kwargs):

        product = representation.product_version.product
        abc_file = cls.get_import_file(session, product.name, 
            product.category, representation)

        alembic_node = session.hou.node('obj').createNode('alembicarchive')
        alembic_node.setParms({"fileName": abc_file})
        alembic_node.parm('buildHierarchy').pressButton()


    # -------------------------------------------------------------------------
    def export(self, *args, **kwargs):
        """Export this entity to a product.""" 
        
        raise EntityError("Houdini geom export not yet supported.")

# -----------------------------------------------------------------------------
EntityRegistry().register('houdini', GeomcacheEntity)

Example #10
0
        product_repr_file = os.path.join(product_repr_dir,
                                         self.display_name + "." + file_type)

        if self.display_name == self.__class__._name_from_context(
                self.session):
            self.session.cmds.file(
                product_repr_file,
                type='mayaAscii',
                exportAll=True,
                force=True,
                preserveReferences=(not bake_references),
            )
        else:
            export_objs = self.get_export_objects()
            with self.session.selected(export_objs):
                self.session.cmds.file(
                    product_repr_file,
                    type='mayaAscii',
                    exportSelected=True,
                    force=True,
                    preserveReferences=(not bake_references),
                )

        product_repr.area.set_permissions(0660)

        return [product_repr]


# -----------------------------------------------------------------------------
EntityRegistry().register('maya', WorkfileEntity)
Example #11
0
    
    # -------------------------------------------------------------------------
    def _ma_export(self, options, product_desc, version_note):

        file_type = 'ma'

        product_repr = self._create_product(product_desc, version_note,
            file_type)
        product_repr_dir = product_repr.directory
        product_repr_file = os.path.join(
            product_repr_dir, self.display_name + "." + file_type)

        export_objs = self.get_export_objects()

        with self.session.selected(export_objs):
            self.session.cmds.file(
                product_repr_file, 
                type='mayaAscii', 
                exportSelected=True,
                force=True, 
                preserveReferences=False,
            )

        product_repr.area.set_permissions(0660)

        return [product_repr]

# -----------------------------------------------------------------------------
EntityRegistry().register('maya', CameraEntity)