mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
covering - more detailed poll messages
This commit is contained in:
@@ -32,9 +32,7 @@ class AddInstanceFlooringCoveringFromCursor(bpy.types.Operator, tool.Ifc.Operato
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
relating_type_id = int(bpy.context.scene.BIMModelProperties.relating_type_id)
|
||||
relating_type = ifcopenshell.util.element.get_predefined_type(tool.Ifc.get().by_id(relating_type_id))
|
||||
return relating_type == "FLOORING"
|
||||
return tool.Covering.covering_poll_relating_type_check(cls, context, "FLOORING")
|
||||
|
||||
def _execute(self, context):
|
||||
try:
|
||||
@@ -51,9 +49,7 @@ class AddInstanceCeilingCoveringFromCursor(bpy.types.Operator, tool.Ifc.Operator
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
relating_type_id = int(bpy.context.scene.BIMModelProperties.relating_type_id)
|
||||
relating_type = ifcopenshell.util.element.get_predefined_type(tool.Ifc.get().by_id(relating_type_id))
|
||||
return relating_type == "CEILING"
|
||||
return tool.Covering.covering_poll_relating_type_check(cls, context, "CEILING")
|
||||
|
||||
def _execute(self, context):
|
||||
try:
|
||||
@@ -70,8 +66,10 @@ class RegenSelectedCoveringObject(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||
return element and element.is_a("IfcCovering")
|
||||
if (obj := context.active_object) and (element := tool.Ifc.get_entity(obj)) and element.is_a("IfcCovering"):
|
||||
return True
|
||||
cls.poll_message_set("IfcCovering must be selected.")
|
||||
return False
|
||||
|
||||
def _execute(self, context):
|
||||
try:
|
||||
@@ -90,11 +88,7 @@ class AddInstanceFlooringCoveringsFromWalls(bpy.types.Operator, tool.Ifc.Operato
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||
relating_type_id = int(bpy.context.scene.BIMModelProperties.relating_type_id)
|
||||
relating_type = ifcopenshell.util.element.get_predefined_type(tool.Ifc.get().by_id(relating_type_id))
|
||||
if element and element.is_a("IfcWall") and tool.Model.get_usage_type(element) == "LAYER2":
|
||||
return context.selected_objects and relating_type == "FLOORING"
|
||||
return tool.Covering.covering_poll_wall_selected(cls, context, "FLOORING")
|
||||
|
||||
def _execute(self, context):
|
||||
# This only works based on a 2D plan only considering the standard
|
||||
@@ -118,11 +112,7 @@ class AddInstanceCeilingCoveringsFromWalls(bpy.types.Operator, tool.Ifc.Operator
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||
relating_type_id = int(bpy.context.scene.BIMModelProperties.relating_type_id)
|
||||
relating_type = ifcopenshell.util.element.get_predefined_type(tool.Ifc.get().by_id(relating_type_id))
|
||||
if element and element.is_a("IfcWall") and tool.Model.get_usage_type(element) == "LAYER2":
|
||||
return context.selected_objects and relating_type == "CEILING"
|
||||
return tool.Covering.covering_poll_wall_selected(cls, context, "CEILING")
|
||||
|
||||
def _execute(self, context):
|
||||
# This only works based on a 2D plan only considering the standard
|
||||
|
||||
@@ -20,6 +20,7 @@ import bpy
|
||||
import bmesh
|
||||
import shapely
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
import blenderbim.core.tool
|
||||
import blenderbim.core.root
|
||||
import blenderbim.core.spatial
|
||||
@@ -37,19 +38,42 @@ class Covering(blenderbim.core.tool.Covering):
|
||||
props = bpy.context.scene.BIMCoveringProperties
|
||||
return props.ceiling_height
|
||||
|
||||
# def toggle_spaces_visibility_wired_and_textured(cls, spaces):
|
||||
# first_obj = tool.Ifc.get_object(spaces[0])
|
||||
# if bpy.data.objects[first_obj.name].display_type == "TEXTURED":
|
||||
# for space in spaces:
|
||||
# obj = tool.Ifc.get_object(space)
|
||||
# bpy.data.objects[obj.name].show_wire = True
|
||||
# bpy.data.objects[obj.name].display_type = "WIRE"
|
||||
# return
|
||||
#
|
||||
# elif bpy.data.objects[first_obj.name].display_type == "WIRE":
|
||||
# for space in spaces:
|
||||
# obj = tool.Ifc.get_object(space)
|
||||
# bpy.data.objects[obj.name].show_wire = False
|
||||
# bpy.data.objects[obj.name].display_type = "TEXTURED"
|
||||
# return
|
||||
|
||||
# def toggle_spaces_visibility_wired_and_textured(cls, spaces):
|
||||
# first_obj = tool.Ifc.get_object(spaces[0])
|
||||
# if bpy.data.objects[first_obj.name].display_type == "TEXTURED":
|
||||
# for space in spaces:
|
||||
# obj = tool.Ifc.get_object(space)
|
||||
# bpy.data.objects[obj.name].show_wire = True
|
||||
# bpy.data.objects[obj.name].display_type = "WIRE"
|
||||
# return
|
||||
#
|
||||
# elif bpy.data.objects[first_obj.name].display_type == "WIRE":
|
||||
# for space in spaces:
|
||||
# obj = tool.Ifc.get_object(space)
|
||||
# bpy.data.objects[obj.name].show_wire = False
|
||||
# bpy.data.objects[obj.name].display_type = "TEXTURED"
|
||||
# return
|
||||
@classmethod
|
||||
def covering_poll_wall_selected(
|
||||
cls, operator: type[bpy.types.Operator], context: bpy.types.Context, covering_type: str
|
||||
) -> bool:
|
||||
if not context.selected_objects or not context.active_object:
|
||||
operator.poll_message_set("No objects selected.")
|
||||
return False
|
||||
element = tool.Ifc.get_entity(context.active_object)
|
||||
if not element or not element.is_a("IfcWall") or not tool.Model.get_usage_type(element) == "LAYER2":
|
||||
operator.poll_message_set("LAYER2 based IfcWall must be selected.")
|
||||
return False
|
||||
return cls.covering_poll_relating_type_check(operator, context, covering_type)
|
||||
|
||||
@classmethod
|
||||
def covering_poll_relating_type_check(
|
||||
cls, operator: type[bpy.types.Operator], context: bpy.types.Context, covering_type: str
|
||||
) -> bool:
|
||||
relating_type_id = int(context.scene.BIMModelProperties.relating_type_id)
|
||||
relating_type = ifcopenshell.util.element.get_predefined_type(tool.Ifc.get().by_id(relating_type_id))
|
||||
if relating_type != covering_type:
|
||||
operator.poll_message_set(f"Select IfcCoveringType with predefined type '{covering_type}'.")
|
||||
return False
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user