diff --git a/src/blenderbim/blenderbim/bim/module/light/__init__.py b/src/blenderbim/blenderbim/bim/module/light/__init__.py index 664eb27f41..17caf43c08 100644 --- a/src/blenderbim/blenderbim/bim/module/light/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/light/__init__.py @@ -19,6 +19,15 @@ import bpy from . import ui, prop, operator +import stat +from pathlib import Path + +import importlib +import pyradiance + +def get_pyradiance_path(): + return importlib.util.find_spec('pyradiance').submodule_search_locations[0] + classes = ( operator.ExportOBJ, @@ -38,6 +47,12 @@ classes = ( def register(): bpy.types.Scene.radiance_exporter_properties = bpy.props.PointerProperty(type=prop.RadianceExporterProperties) bpy.types.Scene.BIMSolarProperties = bpy.props.PointerProperty(type=prop.BIMSolarProperties) + pyradiance_path = Path(get_pyradiance_path()) + bin_path = pyradiance_path / "bin" + if bin_path.exists(): + for file in bin_path.iterdir(): + if file.is_file(): + file.chmod(file.stat().st_mode | stat.S_IEXEC) def unregister(): diff --git a/src/blenderbim/blenderbim/bim/module/light/materials.json b/src/blenderbim/blenderbim/bim/module/light/materials.json index 6d07a6c014..19215a8ee6 100644 --- a/src/blenderbim/blenderbim/bim/module/light/materials.json +++ b/src/blenderbim/blenderbim/bim/module/light/materials.json @@ -5,6 +5,23 @@ "Black Ceiling 2": "void plastic black_ceiling\n0\n0\n5 0.1116 0.1085 0.0938 0.0000 0.0000", "Plastic Ceiling Vent E14 526": "void plastic plastic_ceiling_vent_e14_526\n0\n0\n5 0.7384 0.7195 0.6540 0.0110 0.0500", "Specular Reflective Ceiling Panels": "void plastic specular_reflective_ceiling_panels\n0\n0\n5 0.7708 0.7673 0.6819 0.0741 0.0500" + }, + "Door": { + "Wooden Door": "void plastic wooden_door\n0\n0\n5 0.6164 0.4257 0.2156 0.0185 0.2000", + "Wooden Door 2": "void plastic wooden_door_2\n0\n0\n5 0.0403 0.0388 0.0406 0.0121 0.2000", + "White Wooden Door": "void plastic white_wooden_door\n0\n0\n5 0.7893 0.7502 0.6413 0.0080 0.2000", + "Off White Door": "void plastic off_white_door\n0\n0\n5 0.8607 0.8611 0.7852 0.0258 0.2000", + "Bedroom Door": "void plastic bedroom_door\n0\n0\n5 0.2508 0.0782 0.0111 0.0279 0.2000" + }, + "Floor": { + "Light Blue Ceramic": "void plastic light_blue_ceramic\n0\n0\n5 0.7477 0.7776 0.7807 0.0323 0.1000", + "Light Grey Ceramic": "void plastic light_grey_ceramic\n0\n0\n5 0.6386 0.5941 0.4982 0.0106 0.2000", + "Purple Carpet": "void plastic purple_carpet\n0\n0\n5 0.0425 0.0179 0.0371 0.0001 0.3000" + }, + "Wall": { + "Dirty Dark Pink Painted Wall": "void plastic dirty_dark_pink_painted_wall\n0\n0\n5 0.3533 0.1751 0.1690 0.0000 0.2000", + "Blue Green Painted Walls": "void plastic blue_green_painted_walls\n0\n0\n5 -0.0013 0.2092 0.2601 0.0140 0.2000", + "Red Painted Wall": "void plastic red_painted_wall\n0\n0\n5 0.4621 0.0156 0.0091 0.0396 0.2000" } } ] diff --git a/src/blenderbim/blenderbim/bim/module/light/operator.py b/src/blenderbim/blenderbim/bim/module/light/operator.py index b33662dff1..29326608d5 100644 --- a/src/blenderbim/blenderbim/bim/module/light/operator.py +++ b/src/blenderbim/blenderbim/bim/module/light/operator.py @@ -71,9 +71,6 @@ class ExportOBJ(bpy.types.Operator): ifc_file_path = context.scene.radiance_exporter_properties.ifc_file ifc_file = ifcopenshell.open(ifc_file_path) - # for material in ifc_file.by_type("IfcMaterial"): - # self.report({'INFO'}, f"Material: {material.Name}, ID: {material.id()}") - obj_file_path = os.path.join(output_dir, "model.obj") mtl_file_path = os.path.join(output_dir, "model.mtl") @@ -140,12 +137,17 @@ class RadianceRender(bpy.types.Operator): obj_file_path = os.path.join(output_dir, "model.obj") -<<<<<<< Updated upstream -======= + sun_props = context.scene.BIMSolarProperties sky_file_path = os.path.join(output_dir, "sky.rad") + latitude = sun_props.latitude + longitude = sun_props.longitude + timezone = sun_props.timezone + month = sun_props.month + day = sun_props.day + hour = sun_props.hour + minute = sun_props.minute ->>>>>>> Stashed changes camera = self.get_active_camera(context) if camera is None: self.report({"ERROR"}, "No active camera found in the scene. Please add a camera and set it as active.") @@ -154,60 +156,33 @@ class RadianceRender(bpy.types.Operator): # Get camera position and direction camera_position, camera_direction = self.get_camera_data(camera) -<<<<<<< Updated upstream - # Material processing - # style = [] - # with open(obj_file_path, "r") as obj_file: - # for line in obj_file: - # if line.startswith("usemtl"): - # l = line.strip().split(" ") - # style.append(l[1]) - -======= - - dt = datetime(2024, 7, 29, 12, 0) # July 29, 2024, at 12:00 PM - latitude = 40.7128 # New York City latitude - longitude = -74.0060 # New York City longitude - timezone = -4 # Eastern Daylight Time (EDT) + dt = datetime(2024, month, day, hour, minute) sky_description = pr.gensky( dt=dt, latitude=latitude, longitude=longitude, timezone=timezone, - sunny_with_sun=True, # Assuming a sunny day with visible sun - ground_reflectance=0.2, # Typical ground reflectance value - turbidity=3.0 # Clear sky condition + sunny_with_sun=True, + ground_reflectance=0.2, + turbidity=3.0 ) sky_description_str = sky_description.decode('utf-8') - # Print the generated sky description - print(sky_description_str) - with open(sky_file_path, 'w') as f: f.write(sky_description_str) ->>>>>>> Stashed changes - # Check if json file is empty or not + props = context.scene.radiance_exporter_properties if props.use_json_file: - # Load data from JSON file with open(props.json_file, "r") as file: data = json.load(file) else: - # Use in-UI material mappings data = props.get_mappings_dict() -<<<<<<< Updated upstream - - print(data) - -======= ->>>>>>> Stashed changes - # Create materials.rad file materials_file = os.path.join(output_dir, "materials.rad") with open(materials_file, "w") as file: file.write("void plastic white\n0\n0\n5 0.8 0.8 0.8 0 0\n") @@ -221,10 +196,6 @@ class RadianceRender(bpy.types.Operator): for style_id, radiance_material in data.items(): print(style_id, radiance_material) file.write("inherit alias " + style_id + " " + data.get(style_id, "white") + "\n") - # file.write(f"inherit alias {style_id} {radiance_material}\n") - # for i in set(ifc_materials): - # print(i) - # file.write("inherit alias " + i + " " + data.get(i, "white") + "\n") self.report({"INFO"}, "Exported Materials Rad file to: {}".format(materials_file)) @@ -235,7 +206,6 @@ class RadianceRender(bpy.types.Operator): self.report({"INFO"}, "obj2mesh output: {}".format(mesh_file_path)) scene_file = os.path.join(output_dir, "scene.rad") with open(scene_file, "w") as file: - # file.write("void mesh model\n1 " + rtm_file_path + "\n0\n0\n") file.write('void mesh model\n1 "' + rtm_file_path + '"\n0\n0\n') self.report({"INFO"}, "Exported Scene file to: {}".format(scene_file)) @@ -248,7 +218,7 @@ class RadianceRender(bpy.types.Operator): scene.add_material(material_path) scene.add_surface(scene_path) - scene.add_sky(sky_file_path) + scene.add_source(sky_file_path) aview = pr.View(position=camera_position, direction=camera_direction) scene.add_view(aview) diff --git a/src/blenderbim/blenderbim/bim/module/light/prop.py b/src/blenderbim/blenderbim/bim/module/light/prop.py index 0029972e18..5d989cb762 100644 --- a/src/blenderbim/blenderbim/bim/module/light/prop.py +++ b/src/blenderbim/blenderbim/bim/module/light/prop.py @@ -23,7 +23,7 @@ import datetime import blenderbim.tool as tool from math import radians, pi from mathutils import Euler, Vector, Matrix, Quaternion -from bpy.props import IntProperty, StringProperty, EnumProperty, FloatProperty, FloatVectorProperty, BoolProperty +from bpy.props import IntProperty, StringProperty, EnumProperty, FloatProperty, FloatVectorProperty, BoolProperty, CollectionProperty from bpy.types import PropertyGroup from blenderbim.bim.module.light.data import SolarData from blenderbim.bim.module.light.decorator import SolarDecorator @@ -182,6 +182,7 @@ class RadianceExporterProperties(PropertyGroup): ) material_mappings: bpy.props.CollectionProperty(type=bpy.types.PropertyGroup, name="Material Mappings") + # material_mappings: CollectionProperty(type=MaterialMapping) should_load_from_memory: BoolProperty( name="Load from Memory",