mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Initial Commit
This commit is contained in:
@@ -26,6 +26,7 @@ classes = (
|
||||
operator.EnableReassignClass,
|
||||
operator.ReassignClass,
|
||||
operator.UnlinkObject,
|
||||
operator.BIM_OT_root_property_textfield,
|
||||
prop.BIMRootProperties,
|
||||
ui.BIM_PT_class,
|
||||
)
|
||||
|
||||
@@ -31,7 +31,7 @@ import blenderbim.core.root as core
|
||||
import blenderbim.tool as tool
|
||||
from ifcopenshell.api.void.data import Data as VoidData
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from blenderbim.bim.module.root.prop import get_contexts
|
||||
from blenderbim.bim.module.root.prop import get_contexts, get_ifc_classes_filtered
|
||||
|
||||
|
||||
class Operator:
|
||||
@@ -189,3 +189,24 @@ class CopyClass(bpy.types.Operator, Operator):
|
||||
for obj in objects:
|
||||
core.copy_class(tool.Ifc, tool.Collector, tool.Geometry, tool.Root, obj=obj)
|
||||
blenderbim.bim.handler.purge_module_data()
|
||||
|
||||
|
||||
class BIM_OT_root_property_textfield(bpy.types.Operator):
|
||||
bl_idname = "bim.root_ifc_class_filter"
|
||||
bl_label = "Filter Property"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def invoke(self, context, event):
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.BIMRootProperties.ifc_class = context.scene.BIMRootProperties.ifc_class_filter_enum
|
||||
return {"FINISHED"}
|
||||
|
||||
def draw(self, context):
|
||||
props = context.scene.BIMRootProperties
|
||||
self.layout.prop(props, "ifc_class_filter_textfield")
|
||||
if len(get_ifc_classes_filtered(props, context)) > 10:
|
||||
self.layout.prop(props, "ifc_class_filter_enum")
|
||||
else:
|
||||
self.layout.props_enum(props, "ifc_class_filter_enum")
|
||||
|
||||
@@ -34,11 +34,14 @@ from bpy.props import (
|
||||
)
|
||||
|
||||
types_enum = []
|
||||
classes_enum = []
|
||||
|
||||
|
||||
def purge():
|
||||
global types_enum
|
||||
types_enum = []
|
||||
global classes_enum
|
||||
classes_enum = []
|
||||
|
||||
|
||||
def getIfcPredefinedTypes(self, context):
|
||||
@@ -69,6 +72,10 @@ def refreshPredefinedTypes(self, context):
|
||||
context.scene.BIMRootProperties.ifc_predefined_type = enum[0][0]
|
||||
|
||||
|
||||
def update_class_enum(self, context):
|
||||
self.ifc_class = self.ifc_class_filter_enum
|
||||
|
||||
|
||||
def get_ifc_products(self, context):
|
||||
if not IfcClassData.is_loaded:
|
||||
IfcClassData.load()
|
||||
@@ -81,6 +88,15 @@ def get_ifc_classes(self, context):
|
||||
return IfcClassData.data["ifc_classes"]
|
||||
|
||||
|
||||
def get_ifc_classes_filtered(self, context):
|
||||
ifc_classes = get_ifc_classes(self, context)
|
||||
global classes_enum
|
||||
classes_enum = [
|
||||
c for c in ifc_classes
|
||||
if self.ifc_class_filter_textfield.lower() in c[0].lower()] or ifc_classes
|
||||
return classes_enum
|
||||
|
||||
|
||||
def get_contexts(self, context):
|
||||
if not IfcClassData.is_loaded:
|
||||
IfcClassData.load()
|
||||
@@ -91,5 +107,7 @@ class BIMRootProperties(PropertyGroup):
|
||||
contexts: EnumProperty(items=get_contexts, name="Contexts")
|
||||
ifc_product: EnumProperty(items=get_ifc_products, name="Products", update=refresh_classes)
|
||||
ifc_class: EnumProperty(items=get_ifc_classes, name="Class", update=refreshPredefinedTypes)
|
||||
ifc_class_filter_textfield: StringProperty(name="Filter", options={"TEXTEDIT_UPDATE"})
|
||||
ifc_class_filter_enum: EnumProperty(items=get_ifc_classes_filtered, name="Class", update=update_class_enum)
|
||||
ifc_predefined_type: EnumProperty(items=getIfcPredefinedTypes, name="Predefined Type", default=None)
|
||||
ifc_userdefined_type: StringProperty(name="Userdefined Type")
|
||||
|
||||
@@ -79,8 +79,9 @@ class BIM_PT_class(Panel):
|
||||
if not is_reassigning_class:
|
||||
row = self.layout.row()
|
||||
row.prop(props, "ifc_product")
|
||||
row = self.layout.row()
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(props, "ifc_class")
|
||||
row.operator("bim.root_ifc_class_filter", text="", icon="VIEWZOOM")
|
||||
if ifc_predefined_types:
|
||||
row = self.layout.row()
|
||||
row.prop(props, "ifc_predefined_type")
|
||||
|
||||
Reference in New Issue
Block a user