mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-02 18:36:26 +00:00
Automatically merge excessive styles when loading models
Came across this problem with some models from 12D
This commit is contained in:
@@ -20,6 +20,7 @@ from __future__ import annotations
|
|||||||
import bpy
|
import bpy
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
|
import ifcpatch
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
import mathutils
|
import mathutils
|
||||||
@@ -952,7 +953,12 @@ class IfcImporter:
|
|||||||
props.collection = self.collections[project.GlobalId] = self.project["blender"]
|
props.collection = self.collections[project.GlobalId] = self.project["blender"]
|
||||||
|
|
||||||
def create_styles(self) -> None:
|
def create_styles(self) -> None:
|
||||||
for style in self.file.by_type("IfcSurfaceStyle"):
|
styles = self.file.by_type("IfcSurfaceStyle")
|
||||||
|
if len(styles) > self.ifc_import_settings.style_limit: # Probably something strange happening
|
||||||
|
print("Warning! Excessive styles were found and merged where applicable.")
|
||||||
|
ifcpatch.execute({"file": self.file, "recipe": "MergeStyles", "arguments": []})
|
||||||
|
styles = self.file.by_type("IfcSurfaceStyle")
|
||||||
|
for style in styles:
|
||||||
self.create_style(style)
|
self.create_style(style)
|
||||||
|
|
||||||
def create_style(self, style: ifcopenshell.entity_instance) -> None:
|
def create_style(self, style: ifcopenshell.entity_instance) -> None:
|
||||||
@@ -1132,6 +1138,7 @@ class IfcImportSettings:
|
|||||||
self.deflection_tolerance = 0.001
|
self.deflection_tolerance = 0.001
|
||||||
self.angular_tolerance = 0.5
|
self.angular_tolerance = 0.5
|
||||||
self.void_limit = 30
|
self.void_limit = 30
|
||||||
|
self.style_limit = 300
|
||||||
# Locations greater than 1km are not considered "small sites" according to the georeferencing guide
|
# Locations greater than 1km are not considered "small sites" according to the georeferencing guide
|
||||||
# Users can configure this if they have to handle larger sites but beware of surveying precision
|
# Users can configure this if they have to handle larger sites but beware of surveying precision
|
||||||
self.distance_limit = 1000
|
self.distance_limit = 1000
|
||||||
@@ -1169,6 +1176,7 @@ class IfcImportSettings:
|
|||||||
settings.deflection_tolerance = props.deflection_tolerance
|
settings.deflection_tolerance = props.deflection_tolerance
|
||||||
settings.angular_tolerance = props.angular_tolerance
|
settings.angular_tolerance = props.angular_tolerance
|
||||||
settings.void_limit = props.void_limit
|
settings.void_limit = props.void_limit
|
||||||
|
settings.style_limit = props.style_limit
|
||||||
settings.distance_limit = props.distance_limit
|
settings.distance_limit = props.distance_limit
|
||||||
settings.false_origin_mode = props.false_origin_mode
|
settings.false_origin_mode = props.false_origin_mode
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -318,6 +318,11 @@ class BIMProjectProperties(PropertyGroup):
|
|||||||
default=30,
|
default=30,
|
||||||
description="Maxium number of openings that object can have. If object has more openings, it will be loaded without openings",
|
description="Maxium number of openings that object can have. If object has more openings, it will be loaded without openings",
|
||||||
)
|
)
|
||||||
|
style_limit: IntProperty(
|
||||||
|
name="Style Limit",
|
||||||
|
default=300,
|
||||||
|
description="Maxium number of styles before styles are automatically merged",
|
||||||
|
)
|
||||||
distance_limit: FloatProperty(name="Distance Limit", default=1000, subtype="DISTANCE")
|
distance_limit: FloatProperty(name="Distance Limit", default=1000, subtype="DISTANCE")
|
||||||
false_origin_mode: bpy.props.EnumProperty(
|
false_origin_mode: bpy.props.EnumProperty(
|
||||||
items=[
|
items=[
|
||||||
@@ -454,6 +459,7 @@ class BIMProjectProperties(PropertyGroup):
|
|||||||
deflection_tolerance: float
|
deflection_tolerance: float
|
||||||
angular_tolerance: float
|
angular_tolerance: float
|
||||||
void_limit: int
|
void_limit: int
|
||||||
|
style_limit: int
|
||||||
distance_limit: float
|
distance_limit: float
|
||||||
false_origin_mode: Literal["AUTOMATIC", "MANUAL", "DISABLED"]
|
false_origin_mode: Literal["AUTOMATIC", "MANUAL", "DISABLED"]
|
||||||
false_origin: str
|
false_origin: str
|
||||||
|
|||||||
@@ -213,6 +213,8 @@ class BIM_PT_project(Panel):
|
|||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.prop(pprops, "void_limit")
|
row.prop(pprops, "void_limit")
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
|
row.prop(pprops, "style_limit")
|
||||||
|
row = self.layout.row()
|
||||||
row.prop(pprops, "distance_limit")
|
row.prop(pprops, "distance_limit")
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.prop(pprops, "false_origin_mode")
|
row.prop(pprops, "false_origin_mode")
|
||||||
|
|||||||
Reference in New Issue
Block a user