mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Removed if transparent then glass and removed some comments
This commit is contained in:
@@ -27,12 +27,12 @@ with open(os.path.join(os.path.dirname(__file__), "spectraldb.json"), "r") as 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)
|
||||||
|
|
||||||
# Adding color preview or glass icon
|
# Adding color preview or glass icon
|
||||||
if item.category == "Glass":
|
if item.category == "Glass":
|
||||||
row.label(icon="SHADING_TEXTURE")
|
row.label(icon='SHADING_TEXTURE')
|
||||||
else:
|
else:
|
||||||
color_rect = row.row()
|
color_rect = row.row()
|
||||||
color_rect.prop(item, "color", text="")
|
color_rect.prop(item, "color", text="")
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ from typing import Union, Optional, Sequence
|
|||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
import time
|
import time
|
||||||
import sun_position
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import ifcopenshell.geom
|
import ifcopenshell.geom
|
||||||
@@ -166,21 +165,6 @@ class RadianceRender(bpy.types.Operator):
|
|||||||
sun_props = context.scene.BIMSolarProperties
|
sun_props = context.scene.BIMSolarProperties
|
||||||
sun_pos_props = context.scene.sun_pos_properties
|
sun_pos_props = context.scene.sun_pos_properties
|
||||||
sky_file_path = os.path.join(output_dir, "sky.rad")
|
sky_file_path = os.path.join(output_dir, "sky.rad")
|
||||||
# latitude = sun_props.latitude
|
|
||||||
# longitude = sun_props.longitude
|
|
||||||
# month = sun_props.month
|
|
||||||
# day = sun_props.day
|
|
||||||
# hour = sun_props.hour
|
|
||||||
# minute = sun_props.minute
|
|
||||||
|
|
||||||
# print("Sun Properties:")
|
|
||||||
# print("Latitude: ", latitude)
|
|
||||||
# print("Longitude: ", longitude)
|
|
||||||
# print("Timezone: ", timezone)
|
|
||||||
# print("Month: ", month)
|
|
||||||
# print("Day: ", day)
|
|
||||||
# print("Hour: ", hour)
|
|
||||||
# print("Minute: ", minute)
|
|
||||||
|
|
||||||
print("Setting up camera...")
|
print("Setting up camera...")
|
||||||
if props.use_active_camera:
|
if props.use_active_camera:
|
||||||
@@ -198,15 +182,6 @@ class RadianceRender(bpy.types.Operator):
|
|||||||
print(f"Camera position: {camera_position}")
|
print(f"Camera position: {camera_position}")
|
||||||
print(f"Camera direction: {camera_direction}")
|
print(f"Camera direction: {camera_direction}")
|
||||||
|
|
||||||
# azimuth, elevation = sun_position.sun_calc.get_sun_coordinates(
|
|
||||||
# sun_pos_props.time,
|
|
||||||
# sun_pos_props.latitude,
|
|
||||||
# sun_pos_props.longitude,
|
|
||||||
# -sun_pos_props.UTC_zone,
|
|
||||||
# sun_pos_props.month,
|
|
||||||
# sun_pos_props.day,
|
|
||||||
# sun_pos_props.year,
|
|
||||||
# )
|
|
||||||
|
|
||||||
dt = datetime(sun_pos_props.year, sun_props.month, sun_props.day, sun_props.hour, sun_props.minute)
|
dt = datetime(sun_pos_props.year, sun_props.month, sun_props.day, sun_props.hour, sun_props.minute)
|
||||||
|
|
||||||
@@ -218,11 +193,11 @@ class RadianceRender(bpy.types.Operator):
|
|||||||
longitude=sun_props.longitude,
|
longitude=sun_props.longitude,
|
||||||
year=sun_pos_props.year,
|
year=sun_pos_props.year,
|
||||||
timezone=-int(sun_props.UTC_zone),
|
timezone=-int(sun_props.UTC_zone),
|
||||||
# sunny_with_sun=False,
|
sunny_with_sun=False,
|
||||||
# sunny_without_sun=False,
|
sunny_without_sun=False,
|
||||||
# cloudy=False,
|
cloudy=False,
|
||||||
# ground_reflectance=0.2,
|
ground_reflectance=0.2,
|
||||||
# turbidity=3.0,
|
turbidity=3.0,
|
||||||
)
|
)
|
||||||
|
|
||||||
sky_description_str = sky_description.decode("utf-8")
|
sky_description_str = sky_description.decode("utf-8")
|
||||||
@@ -565,28 +540,22 @@ class RefreshIFCMaterials(bpy.types.Operator):
|
|||||||
if render_item.is_a("IfcSurfaceStyleRendering"):
|
if render_item.is_a("IfcSurfaceStyleRendering"):
|
||||||
style_id = f"IfcSurfaceStyleRendering-{render_item.id()}"
|
style_id = f"IfcSurfaceStyleRendering-{render_item.id()}"
|
||||||
style_name = style.Name or f"Unnamed Style {render_item.id()}"
|
style_name = style.Name or f"Unnamed Style {render_item.id()}"
|
||||||
|
|
||||||
# Extract color and transparency
|
# Extract color
|
||||||
color = (1.0, 1.0, 1.0) # Default white
|
color = (1.0, 1.0, 1.0) # Default white
|
||||||
transparency = 0.0 # Default opaque
|
|
||||||
if render_item.SurfaceColour:
|
if render_item.SurfaceColour:
|
||||||
color = (
|
color = (
|
||||||
render_item.SurfaceColour.Red,
|
render_item.SurfaceColour.Red,
|
||||||
render_item.SurfaceColour.Green,
|
render_item.SurfaceColour.Green,
|
||||||
render_item.SurfaceColour.Blue,
|
render_item.SurfaceColour.Blue
|
||||||
)
|
)
|
||||||
if hasattr(render_item, "Transparency") and render_item.Transparency is not None:
|
|
||||||
transparency = render_item.Transparency
|
|
||||||
|
|
||||||
# Add material with color
|
|
||||||
material = props.add_material_mapping(style_id, style_name)
|
material = props.add_material_mapping(style_id, style_name)
|
||||||
material.color = color
|
material.color = color
|
||||||
|
|
||||||
# If transparency is high, consider it as glass
|
material.category = ""
|
||||||
if transparency > 0.5:
|
material.subcategory = ""
|
||||||
material.category = "Glass"
|
material.is_mapped = False
|
||||||
material.subcategory = "Clear Glass"
|
|
||||||
material.is_mapped = True
|
|
||||||
|
|
||||||
props.active_material_index = 0 if props.materials else -1
|
props.active_material_index = 0 if props.materials else -1
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
from bonsai.bim.helper import prop_with_search
|
||||||
import pytz
|
import pytz
|
||||||
import tzfpy
|
import tzfpy
|
||||||
import json
|
import json
|
||||||
@@ -185,6 +186,8 @@ class RadianceExporterProperties(PropertyGroup):
|
|||||||
if self.ifc_file:
|
if self.ifc_file:
|
||||||
self.ifc_file = bpy.path.abspath(self.ifc_file)
|
self.ifc_file = bpy.path.abspath(self.ifc_file)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_material_mapping(self, style_id, style_name):
|
def add_material_mapping(self, style_id, style_name):
|
||||||
item = self.materials.add()
|
item = self.materials.add()
|
||||||
item.name = style_name
|
item.name = style_name
|
||||||
|
|||||||
Reference in New Issue
Block a user