Esempio n. 1
0
    def execute(self, context):
        # identify all entities' roots in the scene
        rootobjects = ioUtils.getEntityRoots()
        if not rootobjects:
            log("There are no entities to export!", "WARNING")

        # derive entities and export if necessary
        modellist = []
        for root in rootobjects:
            log("Adding entity '" + str(root["entity/name"]) + "' to scene.",
                "INFO")
            if root["entity/type"] in entity_types:
                # TODO delete me?
                # try:
                if (self.exportModels
                        and 'export' in entity_types[root['entity/type']]
                        and root['modelname'] not in models):
                    modelpath = os.path.join(ioUtils.getExportPath(),
                                             self.sceneName, root['modelname'])
                    exportModel(models.deriveModelDictionary(root), modelpath)
                    models.add(root['modelname'])
                # known entity export
                entity = entity_types[root["entity/type"]]['derive'](
                    root, os.path.join(ioUtils.getExportPath(),
                                       self.sceneName))
                # TODO delete me?
                # except KeyError:
                #    log("Required method ""deriveEntity"" not implemented for type " + entity["entity/type"], "ERROR")
                #    continue
            # generic entity export
            else:
                entity = deriveGenericEntity(root)
            exportlist.append(entity)
        return {'FINISHED'}
Esempio n. 2
0
    def execute(self, context):
        """

        Args:
          context: 

        Returns:

        """
        # identify all entities' roots in the scene
        rootobjects = ioUtils.getEntityRoots()
        if not rootobjects:
            log("There are no entities to export!", "WARNING")

        # derive entities and export if necessary
        models = set()
        for root in entities:
            log("Adding entity '" + str(root["entity/name"]) + "' to scene.", "INFO")
            if root["entity/type"] in entity_types:
                # TODO delete me?
                # try:
                if (
                    self.exportModels
                    and 'export' in entity_types[root['entity/type']]
                    and root['model/name'] not in models
                ):
                    modelpath = os.path.join(
                        ioUtils.getExportPath(), self.sceneName, root['model/name']
                    )
                    exportModel(models.deriveModelDictionary(root), modelpath)
                    models.add(root['model/name'])
                # known entity export
                entity = entity_types[root["entity/type"]]['derive'](
                    root, os.path.join(ioUtils.getExportPath(), self.sceneName)
                )
                # TODO delete me?
                # except KeyError:
                #    log("Required method ""deriveEntity"" not implemented for type " + entity["entity/type"], "ERROR")
                #    continue
            # generic entity export
            else:
                entity = deriveGenericEntity(root)
            exportlist.append(entity)
        for scenetype in scene_types:
            typename = "export_scene_" + scenetype
            # check if format exists and should be exported
            if getattr(bpy.context.scene, typename):
                scene_types[scenetype]['export'](
                    exportlist, os.path.join(ioUtils.getExportPath(), self.sceneName)
                )
        return {'FINISHED'}