mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 17:26:30 +00:00
model.space.py - small fixes
This commit is contained in:
@@ -29,13 +29,17 @@ class GenerateSpace(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
bl_idname = "bim.generate_space"
|
bl_idname = "bim.generate_space"
|
||||||
bl_label = "Generate Space"
|
bl_label = "Generate Space"
|
||||||
bl_options = {"REGISTER"}
|
bl_options = {"REGISTER"}
|
||||||
bl_description = "Create a space from the cursor position. Move the cursor position into the desired position, select the right space collection and run the operator"
|
bl_description = (
|
||||||
|
"Create a space from the cursor position. "
|
||||||
|
"Move the cursor position into the desired position, "
|
||||||
|
"select the right space collection and run the operator"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
collection = context.view_layer.active_layer_collection.collection
|
collection = context.view_layer.active_layer_collection.collection
|
||||||
collection_obj = collection.BIMCollectionProperties.obj
|
collection_obj = collection.BIMCollectionProperties.obj
|
||||||
active_obj = bpy.context.active_object
|
active_obj = context.active_object
|
||||||
element = tool.Ifc.get_entity(active_obj)
|
element = tool.Ifc.get_entity(active_obj)
|
||||||
return tool.Ifc.get_entity(collection_obj) and not element.is_a("IfcWall")
|
return tool.Ifc.get_entity(collection_obj) and not element.is_a("IfcWall")
|
||||||
|
|
||||||
@@ -47,16 +51,14 @@ class GenerateSpace(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
def msg(self, context):
|
def msg(self, context):
|
||||||
self.layout.label(text="NO ACTIVE STOREY")
|
self.layout.label(text="NO ACTIVE STOREY")
|
||||||
|
|
||||||
# props = context.scene.BIMModelProperties
|
|
||||||
|
|
||||||
collection = context.view_layer.active_layer_collection.collection
|
collection = context.view_layer.active_layer_collection.collection
|
||||||
collection_obj = collection.BIMCollectionProperties.obj
|
collection_obj = collection.BIMCollectionProperties.obj
|
||||||
if not collection_obj:
|
if not collection_obj:
|
||||||
bpy.context.window_manager.popup_menu(msg, title="Error", icon="ERROR")
|
context.window_manager.popup_menu(msg, title="Error", icon="ERROR")
|
||||||
return
|
return
|
||||||
spatial_element = tool.Ifc.get_entity(collection_obj)
|
spatial_element = tool.Ifc.get_entity(collection_obj)
|
||||||
if not spatial_element:
|
if not spatial_element:
|
||||||
bpy.context.window_manager.popup_menu(msg, title="Error", icon="ERROR")
|
context.window_manager.popup_menu(msg, title="Error", icon="ERROR")
|
||||||
return
|
return
|
||||||
|
|
||||||
core.generate_space(tool.Ifc, tool.Spatial, tool.Model, tool.Type)
|
core.generate_space(tool.Ifc, tool.Spatial, tool.Model, tool.Type)
|
||||||
@@ -70,7 +72,7 @@ class GenerateSpacesFromWalls(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
active_obj = bpy.context.active_object
|
active_obj = context.active_object
|
||||||
element = tool.Ifc.get_entity(active_obj)
|
element = tool.Ifc.get_entity(active_obj)
|
||||||
if element:
|
if element:
|
||||||
return context.selected_objects and element.is_a("IfcWall")
|
return context.selected_objects and element.is_a("IfcWall")
|
||||||
@@ -81,7 +83,7 @@ class GenerateSpacesFromWalls(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
# In order to run, the active object must be a wall and
|
# In order to run, the active object must be a wall and
|
||||||
# there must be selected walls
|
# there must be selected walls
|
||||||
|
|
||||||
active_obj = bpy.context.active_object
|
active_obj = context.active_object
|
||||||
element = tool.Ifc.get_entity(active_obj)
|
element = tool.Ifc.get_entity(active_obj)
|
||||||
container = tool.Spatial.get_container(element)
|
container = tool.Spatial.get_container(element)
|
||||||
|
|
||||||
@@ -96,28 +98,30 @@ class GenerateSpacesFromWalls(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
if not container:
|
if not container:
|
||||||
self.report({"ERROR"}, "The wall is not contained.")
|
self.report({"ERROR"}, "The wall is not contained.")
|
||||||
|
|
||||||
if not bpy.context.selected_objects:
|
if not context.selected_objects:
|
||||||
self.report({"ERROR"}, "No selected objects found. Please select walls.")
|
self.report({"ERROR"}, "No selected objects found. Please select walls.")
|
||||||
return
|
return
|
||||||
|
|
||||||
core.generate_spaces_from_walls(tool.Ifc, tool.Spatial, tool.Collector)
|
core.generate_spaces_from_walls(tool.Ifc, tool.Spatial, tool.Collector)
|
||||||
|
|
||||||
|
|
||||||
class ToggleSpaceVisibility(bpy.types.Operator, tool.Ifc.Operator):
|
class ToggleSpaceVisibility(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.toggle_space_visibility"
|
bl_idname = "bim.toggle_space_visibility"
|
||||||
bl_label = "Toggle Space Visibility"
|
bl_label = "Toggle Space Visibility"
|
||||||
bl_options = {"REGISTER"}
|
bl_options = {"REGISTER"}
|
||||||
bl_description = "Change the space visibility"
|
bl_description = "Change the space visibility"
|
||||||
|
|
||||||
def execute(cls, context):
|
def execute(self, context):
|
||||||
core.toggle_space_visibility(tool.Ifc, tool.Spatial)
|
core.toggle_space_visibility(tool.Ifc, tool.Spatial)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class ToggleHideSpaces(bpy.types.Operator, tool.Ifc.Operator):
|
class ToggleHideSpaces(bpy.types.Operator, tool.Ifc.Operator):
|
||||||
bl_idname = "bim.toggle_hide_spaces"
|
bl_idname = "bim.toggle_hide_spaces"
|
||||||
bl_label = "Toggle Hide Spaces"
|
bl_label = "Toggle Hide Spaces"
|
||||||
bl_options = {"REGISTER"}
|
bl_options = {"REGISTER"}
|
||||||
bl_description = "Hide or Unhide all spaces"
|
bl_description = "Hide or Unhide all spaces"
|
||||||
|
|
||||||
def execute(cls, context):
|
def execute(self, context):
|
||||||
core.toggle_hide_spaces(tool.Ifc, tool.Spatial)
|
core.toggle_hide_spaces(tool.Ifc, tool.Spatial)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|||||||
Reference in New Issue
Block a user