mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
Ran Black Formatting
This commit is contained in:
@@ -2,17 +2,18 @@ import bpy
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
with open(os.path.join(os.path.dirname(__file__), "spectraldb.json"), 'r') as f:
|
with open(os.path.join(os.path.dirname(__file__), "spectraldb.json"), "r") as f:
|
||||||
spectraldb = json.load(f)
|
spectraldb = json.load(f)
|
||||||
|
|
||||||
|
|
||||||
class MATERIAL_UL_radiance_materials(bpy.types.UIList):
|
class MATERIAL_UL_radiance_materials(bpy.types.UIList):
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
|
||||||
if self.layout_type in {'DEFAULT', 'COMPACT'}:
|
if self.layout_type in {"DEFAULT", "COMPACT"}:
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(item, "name", text="", emboss=False, icon_value=icon)
|
row.prop(item, "name", text="", emboss=False, icon_value=icon)
|
||||||
if item.is_mapped:
|
if item.is_mapped:
|
||||||
row.label(text=f"{item.category} - {item.subcategory}")
|
row.label(text=f"{item.category} - {item.subcategory}")
|
||||||
op = row.operator("bim.unmap_material", text="", icon='X')
|
op = row.operator("bim.unmap_material", text="", icon="X")
|
||||||
op.material_index = index
|
op.material_index = index
|
||||||
else:
|
else:
|
||||||
row.label(text="Not Mapped (White)")
|
row.label(text="Not Mapped (White)")
|
||||||
@@ -38,7 +38,7 @@ from blenderbim.bim.module.light.data import SolarData
|
|||||||
|
|
||||||
ifc_materials = []
|
ifc_materials = []
|
||||||
|
|
||||||
with open(os.path.join(os.path.dirname(__file__), "spectraldb.json"), 'r') as f:
|
with open(os.path.join(os.path.dirname(__file__), "spectraldb.json"), "r") as f:
|
||||||
spectraldb = json.load(f)
|
spectraldb = json.load(f)
|
||||||
|
|
||||||
|
|
||||||
@@ -171,8 +171,6 @@ class RadianceRender(bpy.types.Operator):
|
|||||||
print("Hour: ", hour)
|
print("Hour: ", hour)
|
||||||
print("Minute: ", minute)
|
print("Minute: ", minute)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
camera = self.get_active_camera(context)
|
camera = self.get_active_camera(context)
|
||||||
if camera is None:
|
if camera is None:
|
||||||
self.report({"ERROR"}, "No active camera found in the scene. Please add a camera and set it as active.")
|
self.report({"ERROR"}, "No active camera found in the scene. Please add a camera and set it as active.")
|
||||||
@@ -517,14 +515,14 @@ class RefreshIFCMaterials(bpy.types.Operator):
|
|||||||
|
|
||||||
props.active_material_index = 0 if props.materials else -1
|
props.active_material_index = 0 if props.materials else -1
|
||||||
|
|
||||||
self.report({'INFO'}, f"Refreshed {len(props.materials)} IFC materials")
|
self.report({"INFO"}, f"Refreshed {len(props.materials)} IFC materials")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class UnmapMaterial(bpy.types.Operator):
|
class UnmapMaterial(bpy.types.Operator):
|
||||||
bl_idname = "bim.unmap_material"
|
bl_idname = "bim.unmap_material"
|
||||||
bl_label = "Unmap Material"
|
bl_label = "Unmap Material"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
material_index: bpy.props.IntProperty()
|
material_index: bpy.props.IntProperty()
|
||||||
|
|
||||||
@@ -532,4 +530,4 @@ class UnmapMaterial(bpy.types.Operator):
|
|||||||
props = context.scene.radiance_exporter_properties
|
props = context.scene.radiance_exporter_properties
|
||||||
material = props.materials[self.material_index]
|
material = props.materials[self.material_index]
|
||||||
props.unmap_material(material.name)
|
props.unmap_material(material.name)
|
||||||
return {'FINISHED'}
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ from blenderbim.bim.module.light.decorator import SolarDecorator
|
|||||||
|
|
||||||
sun_position = tool.Blender.get_sun_position_addon()
|
sun_position = tool.Blender.get_sun_position_addon()
|
||||||
|
|
||||||
with open(os.path.join(os.path.dirname(__file__), "spectraldb.json"), 'r') as f:
|
with open(os.path.join(os.path.dirname(__file__), "spectraldb.json"), "r") as f:
|
||||||
spectraldb = json.load(f)
|
spectraldb = json.load(f)
|
||||||
|
|
||||||
|
|
||||||
@@ -163,6 +163,7 @@ class RadianceMaterial(PropertyGroup):
|
|||||||
subcategory: StringProperty(name="Subcategory")
|
subcategory: StringProperty(name="Subcategory")
|
||||||
is_mapped: BoolProperty(name="Is Mapped", default=False)
|
is_mapped: BoolProperty(name="Is Mapped", default=False)
|
||||||
|
|
||||||
|
|
||||||
class RadianceExporterProperties(PropertyGroup):
|
class RadianceExporterProperties(PropertyGroup):
|
||||||
|
|
||||||
def update_json_file(self, context):
|
def update_json_file(self, context):
|
||||||
@@ -199,7 +200,11 @@ class RadianceExporterProperties(PropertyGroup):
|
|||||||
self.materials[-1].subcategory = subcategory
|
self.materials[-1].subcategory = subcategory
|
||||||
|
|
||||||
def get_mappings_dict(self):
|
def get_mappings_dict(self):
|
||||||
return {item.style_id: (item.category, item.subcategory) for item in self.materials if item.category and item.subcategory}
|
return {
|
||||||
|
item.style_id: (item.category, item.subcategory)
|
||||||
|
for item in self.materials
|
||||||
|
if item.category and item.subcategory
|
||||||
|
}
|
||||||
|
|
||||||
def unmap_material(self, style_name):
|
def unmap_material(self, style_name):
|
||||||
item = self.get_material_mapping(style_name)
|
item = self.get_material_mapping(style_name)
|
||||||
@@ -219,19 +224,19 @@ class RadianceExporterProperties(PropertyGroup):
|
|||||||
)
|
)
|
||||||
|
|
||||||
categories = [
|
categories = [
|
||||||
('Wall', 'Wall', ''),
|
("Wall", "Wall", ""),
|
||||||
('Floor', 'Floor', ''),
|
("Floor", "Floor", ""),
|
||||||
('Ceiling', 'Ceiling', ''),
|
("Ceiling", "Ceiling", ""),
|
||||||
('Door', 'Door', ''),
|
("Door", "Door", ""),
|
||||||
('Furniture', 'Furniture', ''),
|
("Furniture", "Furniture", ""),
|
||||||
('Exterior Floor', 'Exterior Floor', ''),
|
("Exterior Floor", "Exterior Floor", ""),
|
||||||
('Others', 'Others', ''),
|
("Others", "Others", ""),
|
||||||
('Exterior Building', 'Exterior Building', ''),
|
("Exterior Building", "Exterior Building", ""),
|
||||||
('Window Mullion', 'Window Mullion', ''),
|
("Window Mullion", "Window Mullion", ""),
|
||||||
('PV', 'PV', ''),
|
("PV", "PV", ""),
|
||||||
('Plant', 'Plant', ''),
|
("Plant", "Plant", ""),
|
||||||
('Exterior', 'Exterior', ''),
|
("Exterior", "Exterior", ""),
|
||||||
('Color Swatch', 'Color Swatch', ''),
|
("Color Swatch", "Color Swatch", ""),
|
||||||
]
|
]
|
||||||
|
|
||||||
def update_material_mapping(self, context):
|
def update_material_mapping(self, context):
|
||||||
@@ -243,22 +248,16 @@ class RadianceExporterProperties(PropertyGroup):
|
|||||||
print(f"Material '{active_material.name}' mapped to {self.category} - {self.subcategory}")
|
print(f"Material '{active_material.name}' mapped to {self.category} - {self.subcategory}")
|
||||||
|
|
||||||
category: bpy.props.EnumProperty(
|
category: bpy.props.EnumProperty(
|
||||||
items=categories,
|
items=categories, name="Category", description="Material category", update=update_material_mapping
|
||||||
name="Category",
|
|
||||||
description="Material category",
|
|
||||||
update=update_material_mapping
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_subcategories(self, context):
|
def get_subcategories(self, context):
|
||||||
if self.category in spectraldb:
|
if self.category in spectraldb:
|
||||||
return [(k, k, '') for k in spectraldb[self.category].keys()]
|
return [(k, k, "") for k in spectraldb[self.category].keys()]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
subcategory: bpy.props.EnumProperty(
|
subcategory: bpy.props.EnumProperty(
|
||||||
items=get_subcategories,
|
items=get_subcategories, name="Subcategory", description="Material subcategory", update=update_material_mapping
|
||||||
name="Subcategory",
|
|
||||||
description="Material subcategory",
|
|
||||||
update=update_material_mapping
|
|
||||||
)
|
)
|
||||||
|
|
||||||
materials: CollectionProperty(type=RadianceMaterial)
|
materials: CollectionProperty(type=RadianceMaterial)
|
||||||
|
|||||||
@@ -71,14 +71,15 @@ class BIM_PT_radiance_exporter(bpy.types.Panel):
|
|||||||
if props.active_material_index >= 0 and props.active_material_index < len(props.materials):
|
if props.active_material_index >= 0 and props.active_material_index < len(props.materials):
|
||||||
active_material = props.materials[props.active_material_index]
|
active_material = props.materials[props.active_material_index]
|
||||||
if active_material.category and active_material.subcategory:
|
if active_material.category and active_material.subcategory:
|
||||||
layout.label(text=f"Mapped: {active_material.name} to {active_material.category} - {active_material.subcategory}")
|
layout.label(
|
||||||
|
text=f"Mapped: {active_material.name} to {active_material.category} - {active_material.subcategory}"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
layout.label(text=f"Select category and subcategory for: {active_material.name}")
|
layout.label(text=f"Select category and subcategory for: {active_material.name}")
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.operator("bim.refresh_ifc_materials", text="Refresh IFC Materials")
|
row.operator("bim.refresh_ifc_materials", text="Refresh IFC Materials")
|
||||||
|
|
||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.label(text="Resolution")
|
row.label(text="Resolution")
|
||||||
|
|||||||
Reference in New Issue
Block a user