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'}
def execute(self, context): exportlist = [] # TODO variable not used exportsettings = ioUtils.getExpSettings() # identify all entities' roots in the scene entities = ioUtils.getExportEntities() if not entities: log("There are no entities to export!", "WARNING") return {'CANCELLED'} # 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['modelname'] not in models): modelpath = os.path.join(ioUtils.getExportPath(), self.sceneName, root['modelname']) # FIXME: the following is a hack, the problem is that # robots are always smurf entities if root['entity/type'] == 'smurf': formatlist = ['smurf', 'urdf'] else: formatlist = [root['entity/type']] exportModel(root, modelpath, formatlist) 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) for scenetype in scene_types: typename = "export_scene_" + scenetype # check if format exists and should be exported if getattr(bpy.data.worlds[0], typename): scene_types[scenetype]['export'](exportlist, os.path.join( ioUtils.getExportPath(), self.sceneName)) return {'FINISHED'}
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'}