diff --git a/src/blenderbim/blenderbim/bim/__init__.py b/src/blenderbim/blenderbim/bim/__init__.py index 71c088c2f4..5e7e33e165 100644 --- a/src/blenderbim/blenderbim/bim/__init__.py +++ b/src/blenderbim/blenderbim/bim/__init__.py @@ -85,6 +85,7 @@ modules = { "ifcgit": None, "covering": None, "web": None, + "light": None, # Uncomment this line to enable loading of the demo module. Happy hacking! # The name "demo" must correlate to a folder name in `bim/module/`. # "demo": None, diff --git a/src/blenderbim/blenderbim/bim/module/light/__init__.py b/src/blenderbim/blenderbim/bim/module/light/__init__.py new file mode 100644 index 0000000000..5aa65bec18 --- /dev/null +++ b/src/blenderbim/blenderbim/bim/module/light/__init__.py @@ -0,0 +1,37 @@ +# BlenderBIM Add-on - OpenBIM Blender Add-on +# Copyright (C) 2020, 2021 Dion Moult +# +# This file is part of BlenderBIM Add-on. +# +# BlenderBIM Add-on is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# BlenderBIM Add-on is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with BlenderBIM Add-on. If not, see . + +import bpy +from . import ui, prop, operator + + +classes = ( + operator.ExportRadiance, + prop.RadianceExporterProperties, + ui.BIM_PT_radiance_exporter, +) + +def register(): + # for cls in classes: + # bpy.utils.register_class(cls) + bpy.types.Scene.radiance_exporter_properties = bpy.props.PointerProperty(type=prop.RadianceExporterProperties) + +def unregister(): + # for cls in reversed(classes): + # bpy.utils.unregister_class(cls) + del bpy.types.Scene.radiance_exporter_properties \ No newline at end of file diff --git a/src/blenderbim/blenderbim/bim/module/light/operator.py b/src/blenderbim/blenderbim/bim/module/light/operator.py new file mode 100644 index 0000000000..2934b2a422 --- /dev/null +++ b/src/blenderbim/blenderbim/bim/module/light/operator.py @@ -0,0 +1,50 @@ +# BlenderBIM Add-on - OpenBIM Blender Add-on +# Copyright (C) 2020, 2021 Dion Moult +# +# This file is part of BlenderBIM Add-on. +# +# BlenderBIM Add-on is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# BlenderBIM Add-on is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with BlenderBIM Add-on. If not, see . + +import os +import pyradiance as pr +import bpy + +from pathlib import Path +from typing import Union, Optional, Sequence +import json +import ifcopenshell +import ifcopenshell.geom +import multiprocessing + +class ExportRadiance(bpy.types.Operator): + """Exports and renders the scene with Radiance using rad""" + bl_idname = "export_scene.radiance" + bl_label = "Export and Render" + bl_description = "Export the scene to Radiance and render it" + + def execute(self, context): + return {'FINISHED'} + + + def getResolution(self, context): + scene = context.scene + props = scene.radiance_exporter_properties + resolution_x = props.radiance_resolution_x + resolution_y = props.radiance_resolution_y + return resolution_x, resolution_y + +def save_obj2mesh_output(inp: Union[bytes, str, Path], output_file: str, **kwargs): + output_bytes = pr.obj2mesh(inp, **kwargs) + with open(output_file, 'wb') as f: + f.write(output_bytes) \ No newline at end of file diff --git a/src/blenderbim/blenderbim/bim/module/light/prop.py b/src/blenderbim/blenderbim/bim/module/light/prop.py new file mode 100644 index 0000000000..12f7d39d4d --- /dev/null +++ b/src/blenderbim/blenderbim/bim/module/light/prop.py @@ -0,0 +1,70 @@ +# BlenderBIM Add-on - OpenBIM Blender Add-on +# Copyright (C) 2020, 2021 Dion Moult +# +# This file is part of BlenderBIM Add-on. +# +# BlenderBIM Add-on is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# BlenderBIM Add-on is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with BlenderBIM Add-on. If not, see . + +import bpy +from bpy.props import IntProperty, StringProperty, EnumProperty +from bpy.types import PropertyGroup + +class RadianceExporterProperties(PropertyGroup): + radiance_resolution_x: IntProperty( + name="X", + description="Horizontal resolution of the output image", + default=1920, + min=1 + ) + radiance_resolution_y: IntProperty( + name="Y", + description="Vertical resolution of the output image", + default=1080, + min=1 + ) + ifc_file_name: StringProperty( + name="IFC File Name", + description="Name of the IFC file to use (without .ifc extension)", + default="AC20-FZK-Haus" + ) + radiance_quality: EnumProperty( + name="Quality", + description="Radiance rendering quality", + items=[ + ('LOW', "Low", "Low quality"), + ('MEDIUM', "Medium", "Medium quality"), + ('HIGH', "High", "High quality") + ], + default='MEDIUM' + ) + radiance_detail: EnumProperty( + name="Detail", + description="Radiance rendering detail", + items=[ + ('LOW', "Low", "Low detail"), + ('MEDIUM', "Medium", "Medium detail"), + ('HIGH', "High", "High detail") + ], + default='MEDIUM' + ) + radiance_variability: EnumProperty( + name="Variability", + description="Radiance rendering variability", + items=[ + ('LOW', "Low", "Low variability"), + ('MEDIUM', "Medium", "Medium variability"), + ('HIGH', "High", "High variability") + ], + default='MEDIUM' + ) \ No newline at end of file diff --git a/src/blenderbim/blenderbim/bim/module/light/ui.py b/src/blenderbim/blenderbim/bim/module/light/ui.py new file mode 100644 index 0000000000..3abb7d0f79 --- /dev/null +++ b/src/blenderbim/blenderbim/bim/module/light/ui.py @@ -0,0 +1,58 @@ +# BlenderBIM Add-on - OpenBIM Blender Add-on +# Copyright (C) 2020, 2021 Dion Moult +# +# This file is part of BlenderBIM Add-on. +# +# BlenderBIM Add-on is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# BlenderBIM Add-on is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with BlenderBIM Add-on. If not, see . + +import bpy + +class BIM_PT_radiance_exporter(bpy.types.Panel): + """Creates a Panel in the render properties window""" + bl_label = "Radiance Exporter" + bl_idname = "BIM_PT_radiance_exporter" + bl_options = {'DEFAULT_CLOSED'} + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_context = "scene" + bl_parent_id = "BIM_PT_tab_services" + + def draw(self, context): + layout = self.layout + scene = context.scene + + props = scene.radiance_exporter_properties + + row = layout.row() + row.prop(props, "ifc_file_name") + + row = layout.row() + row.label(text="Resolution") + row.prop(props, "radiance_resolution_x", text="X") + + row = layout.row() + row.label(text="") + row.prop(props, "radiance_resolution_y", text="Y") + + row = layout.row() + row.prop(props, "radiance_quality") + + row = layout.row() + row.prop(props, "radiance_detail") + + row = layout.row() + row.prop(props, "radiance_variability") + + row = layout.row() + row.operator("export_scene.radiance", text="Export and Render") \ No newline at end of file