mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Ran Black Formatting
This commit is contained in:
@@ -2,17 +2,18 @@ import bpy
|
||||
import json
|
||||
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)
|
||||
|
||||
|
||||
class MATERIAL_UL_radiance_materials(bpy.types.UIList):
|
||||
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.prop(item, "name", text="", emboss=False, icon_value=icon)
|
||||
if item.is_mapped:
|
||||
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
|
||||
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 = []
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@@ -171,8 +171,6 @@ class RadianceRender(bpy.types.Operator):
|
||||
print("Hour: ", hour)
|
||||
print("Minute: ", minute)
|
||||
|
||||
|
||||
|
||||
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.")
|
||||
@@ -319,7 +317,7 @@ ground_glow source ground
|
||||
for material in default_materials:
|
||||
file.write(material)
|
||||
written_materials.add(material.split()[2]) # Add material name to written set
|
||||
|
||||
|
||||
print(data)
|
||||
print(default_materials)
|
||||
|
||||
@@ -517,19 +515,19 @@ class RefreshIFCMaterials(bpy.types.Operator):
|
||||
|
||||
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"}
|
||||
|
||||
|
||||
class UnmapMaterial(bpy.types.Operator):
|
||||
bl_idname = "bim.unmap_material"
|
||||
bl_label = "Unmap Material"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
material_index: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.radiance_exporter_properties
|
||||
material = props.materials[self.material_index]
|
||||
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()
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@@ -163,6 +163,7 @@ class RadianceMaterial(PropertyGroup):
|
||||
subcategory: StringProperty(name="Subcategory")
|
||||
is_mapped: BoolProperty(name="Is Mapped", default=False)
|
||||
|
||||
|
||||
class RadianceExporterProperties(PropertyGroup):
|
||||
|
||||
def update_json_file(self, context):
|
||||
@@ -199,8 +200,12 @@ class RadianceExporterProperties(PropertyGroup):
|
||||
self.materials[-1].subcategory = subcategory
|
||||
|
||||
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):
|
||||
item = self.get_material_mapping(style_name)
|
||||
if item:
|
||||
@@ -219,19 +224,19 @@ class RadianceExporterProperties(PropertyGroup):
|
||||
)
|
||||
|
||||
categories = [
|
||||
('Wall', 'Wall', ''),
|
||||
('Floor', 'Floor', ''),
|
||||
('Ceiling', 'Ceiling', ''),
|
||||
('Door', 'Door', ''),
|
||||
('Furniture', 'Furniture', ''),
|
||||
('Exterior Floor', 'Exterior Floor', ''),
|
||||
('Others', 'Others', ''),
|
||||
('Exterior Building', 'Exterior Building', ''),
|
||||
('Window Mullion', 'Window Mullion', ''),
|
||||
('PV', 'PV', ''),
|
||||
('Plant', 'Plant', ''),
|
||||
('Exterior', 'Exterior', ''),
|
||||
('Color Swatch', 'Color Swatch', ''),
|
||||
("Wall", "Wall", ""),
|
||||
("Floor", "Floor", ""),
|
||||
("Ceiling", "Ceiling", ""),
|
||||
("Door", "Door", ""),
|
||||
("Furniture", "Furniture", ""),
|
||||
("Exterior Floor", "Exterior Floor", ""),
|
||||
("Others", "Others", ""),
|
||||
("Exterior Building", "Exterior Building", ""),
|
||||
("Window Mullion", "Window Mullion", ""),
|
||||
("PV", "PV", ""),
|
||||
("Plant", "Plant", ""),
|
||||
("Exterior", "Exterior", ""),
|
||||
("Color Swatch", "Color Swatch", ""),
|
||||
]
|
||||
|
||||
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}")
|
||||
|
||||
category: bpy.props.EnumProperty(
|
||||
items=categories,
|
||||
name="Category",
|
||||
description="Material category",
|
||||
update=update_material_mapping
|
||||
items=categories, name="Category", description="Material category", update=update_material_mapping
|
||||
)
|
||||
|
||||
def get_subcategories(self, context):
|
||||
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 []
|
||||
|
||||
subcategory: bpy.props.EnumProperty(
|
||||
items=get_subcategories,
|
||||
name="Subcategory",
|
||||
description="Material subcategory",
|
||||
update=update_material_mapping
|
||||
items=get_subcategories, name="Subcategory", description="Material subcategory", update=update_material_mapping
|
||||
)
|
||||
|
||||
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):
|
||||
active_material = props.materials[props.active_material_index]
|
||||
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:
|
||||
layout.label(text=f"Select category and subcategory for: {active_material.name}")
|
||||
|
||||
|
||||
row = layout.row()
|
||||
row.operator("bim.refresh_ifc_materials", text="Refresh IFC Materials")
|
||||
|
||||
|
||||
layout.separator()
|
||||
row = layout.row()
|
||||
row.label(text="Resolution")
|
||||
|
||||
Reference in New Issue
Block a user