mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Merge pull request #1673 from Gorgious56/improve-object-ux
Improve Object, Material BimProperties UX and fix a few bugs
This commit is contained in:
@@ -110,6 +110,8 @@ class BIM_PT_material_attributes(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
if not IfcStore.get_file():
|
||||
return False
|
||||
try:
|
||||
return bool(context.active_object.active_material.BIMObjectProperties.ifc_definition_id)
|
||||
except:
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import blenderbim.bim.module.classification.prop as classification_prop
|
||||
from bpy.types import Panel, UIList
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from ifcopenshell.api.classification.data import Data
|
||||
@@ -104,7 +105,7 @@ class BIM_PT_classification_references(Panel):
|
||||
if self.oprops.ifc_definition_id not in Data.products:
|
||||
Data.load(IfcStore.get_file(), self.oprops.ifc_definition_id)
|
||||
|
||||
self.draw_add_ui()
|
||||
self.draw_add_ui(context)
|
||||
|
||||
reference_ids = Data.products[self.oprops.ifc_definition_id]
|
||||
if not reference_ids:
|
||||
@@ -118,8 +119,8 @@ class BIM_PT_classification_references(Panel):
|
||||
else:
|
||||
self.draw_ui(reference_id, reference)
|
||||
|
||||
def draw_add_ui(self):
|
||||
if not self.sprops.available_classifications:
|
||||
def draw_add_ui(self, context):
|
||||
if not classification_prop.getClassifications(self.sprops, context):
|
||||
return
|
||||
|
||||
name = Data.library_classifications[int(self.sprops.available_classifications)]
|
||||
|
||||
@@ -47,8 +47,8 @@ class PieAddOpening(bpy.types.Operator):
|
||||
elif len(obj.children) == 1 and not obj.children[0].BIMObjectProperties.ifc_definition_id:
|
||||
opening_name = obj.children[0].name
|
||||
else:
|
||||
opj_name = obj.name
|
||||
bpy.ops.bim.add_opening(obj=opj_name, opening=opening_name)
|
||||
obj_name = obj.name
|
||||
bpy.ops.bim.add_opening(obj=obj_name, opening=opening_name)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ class CreateProject(bpy.types.Operator):
|
||||
return result
|
||||
|
||||
def _execute(self, context):
|
||||
active_object = context.view_layer.objects.active
|
||||
self.file = IfcStore.get_file()
|
||||
if self.file:
|
||||
return {"FINISHED"}
|
||||
@@ -79,6 +80,7 @@ class CreateProject(bpy.types.Operator):
|
||||
bpy.ops.bim.assign_object(related_object=building.name, relating_object=site.name)
|
||||
bpy.ops.bim.assign_object(related_object=building_storey.name, relating_object=building.name)
|
||||
|
||||
context.view_layer.objects.active = active_object
|
||||
return {"FINISHED"}
|
||||
|
||||
def get_name(self, ifc_class, name):
|
||||
|
||||
@@ -207,7 +207,8 @@ class BIM_PT_material_psets(Panel):
|
||||
props = context.active_object.active_material.BIMObjectProperties
|
||||
if not props.ifc_definition_id:
|
||||
return False
|
||||
if IfcStore.get_file().schema == "IFC2X3":
|
||||
file = IfcStore.get_file()
|
||||
if not file or file.schema == "IFC2X3":
|
||||
return False # We don't support material psets in IFC2X3 because they suck
|
||||
if props.ifc_definition_id not in Data.products:
|
||||
Data.load(IfcStore.get_file(), props.ifc_definition_id)
|
||||
|
||||
@@ -72,7 +72,8 @@ def refreshPredefinedTypes(self, context):
|
||||
global types_enum
|
||||
types_enum.clear()
|
||||
enum = getIfcPredefinedTypes(self, context)
|
||||
context.scene.BIMRootProperties.ifc_predefined_type = enum[0][0]
|
||||
if enum:
|
||||
context.scene.BIMRootProperties.ifc_predefined_type = enum[0][0]
|
||||
|
||||
|
||||
def getIfcProducts(self, context):
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import blenderbim.bim.module.root.prop as root_prop
|
||||
from bpy.types import Panel
|
||||
from ifcopenshell.api.root.data import Data
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
@@ -49,7 +50,9 @@ class BIM_PT_class(Panel):
|
||||
row = self.layout.row(align=True)
|
||||
row.operator("bim.reassign_class", icon="CHECKMARK")
|
||||
row.operator("bim.disable_reassign_class", icon="CANCEL", text="")
|
||||
self.draw_class_dropdowns(context)
|
||||
self.draw_class_dropdowns(
|
||||
context,
|
||||
root_prop.getIfcPredefinedTypes(context.scene.BIMRootProperties, context))
|
||||
else:
|
||||
data = Data.products[props.ifc_definition_id]
|
||||
name = data["type"]
|
||||
@@ -72,23 +75,24 @@ class BIM_PT_class(Panel):
|
||||
else:
|
||||
row.operator("bim.unassign_class", icon="X", text="").obj = context.active_object.name
|
||||
else:
|
||||
self.draw_class_dropdowns(context)
|
||||
ifc_predefined_types = root_prop.getIfcPredefinedTypes(context.scene.BIMRootProperties, context)
|
||||
self.draw_class_dropdowns(context, ifc_predefined_types)
|
||||
row = self.layout.row(align=True)
|
||||
op = row.operator("bim.assign_class")
|
||||
op.ifc_class = context.scene.BIMRootProperties.ifc_class
|
||||
op.predefined_type = context.scene.BIMRootProperties.ifc_predefined_type
|
||||
op.predefined_type = context.scene.BIMRootProperties.ifc_predefined_type if ifc_predefined_types else ""
|
||||
op.userdefined_type = context.scene.BIMRootProperties.ifc_userdefined_type
|
||||
|
||||
def draw_class_dropdowns(self, context):
|
||||
def draw_class_dropdowns(self, context, ifc_predefined_types):
|
||||
props = context.scene.BIMRootProperties
|
||||
row = self.layout.row()
|
||||
row.prop(props, "ifc_product")
|
||||
row = self.layout.row()
|
||||
row.prop(props, "ifc_class")
|
||||
if props.ifc_predefined_type:
|
||||
if ifc_predefined_types:
|
||||
row = self.layout.row()
|
||||
row.prop(props, "ifc_predefined_type")
|
||||
if props.ifc_predefined_type == "USERDEFINED":
|
||||
if ifc_predefined_types == "USERDEFINED":
|
||||
row = self.layout.row()
|
||||
row.prop(props, "ifc_userdefined_type")
|
||||
row = self.layout.row()
|
||||
|
||||
@@ -134,7 +134,7 @@ class RemoveContainer(bpy.types.Operator):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
obj = bpy.data.objects.get(self.obj, context.active_object)
|
||||
oprops = obj.BIMObjectProperties
|
||||
self.file = IfcStore.get_file()
|
||||
ifcopenshell.api.run(
|
||||
@@ -152,6 +152,7 @@ class RemoveContainer(bpy.types.Operator):
|
||||
for collection in obj.users_collection:
|
||||
collection.objects.unlink(obj)
|
||||
context.scene.collection.objects.link(obj)
|
||||
context.view_layer.objects.active = obj
|
||||
return {"FINISHED"}
|
||||
|
||||
def remove_collection(self, parent, child):
|
||||
@@ -162,6 +163,11 @@ class RemoveContainer(bpy.types.Operator):
|
||||
|
||||
|
||||
class CopyToContainer(bpy.types.Operator):
|
||||
"""
|
||||
Copies selected objects to selected containers
|
||||
Check the mark next to a container in the container list to select it
|
||||
Several containers can be selected at a time
|
||||
"""
|
||||
bl_idname = "bim.copy_to_container"
|
||||
bl_label = "Copy To Container"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
@@ -172,7 +178,7 @@ class CopyToContainer(bpy.types.Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
objects = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects
|
||||
objects = list(bpy.data.objects.get(self.obj, context.selected_objects))
|
||||
sprops = context.scene.BIMSpatialProperties
|
||||
container_ids = [c.ifc_definition_id for c in sprops.spatial_elements if c.is_selected]
|
||||
for obj in objects:
|
||||
|
||||
@@ -59,6 +59,8 @@ class BIM_PT_style_attributes(Panel):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
if not IfcStore.get_file():
|
||||
return False
|
||||
try:
|
||||
return bool(context.active_object.active_material.BIMMaterialProperties.ifc_style_id)
|
||||
except:
|
||||
|
||||
@@ -136,13 +136,13 @@ class SelectType(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
related_object = bpy.data.objects.get(self.related_object) if self.related_object else context.active_object
|
||||
related_object = bpy.data.objects.get(self.related_object, context.active_object)
|
||||
oprops = related_object.BIMObjectProperties
|
||||
obj = IfcStore.get_element(
|
||||
ifcopenshell.util.element.get_type(self.file.by_id(oprops.ifc_definition_id)).GlobalId
|
||||
)
|
||||
context.view_layer.objects.active = obj
|
||||
obj.select_set(True)
|
||||
element_type = ifcopenshell.util.element.get_type(self.file.by_id(oprops.ifc_definition_id))
|
||||
if element_type is not None:
|
||||
obj = IfcStore.get_element(element_type.GlobalId)
|
||||
context.view_layer.objects.active = obj
|
||||
obj.select_set(True)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
@@ -35,8 +35,10 @@ class AddOpening(bpy.types.Operator):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
opening = bpy.data.objects.get(self.opening)
|
||||
obj = context.scene.objects.get(self.obj, context.active_object)
|
||||
opening = context.scene.objects.get(self.opening)
|
||||
if opening is None:
|
||||
return {"FINISHED"}
|
||||
opening.display_type = "WIRE"
|
||||
if not opening.BIMObjectProperties.ifc_definition_id:
|
||||
body_context_id = None
|
||||
@@ -118,8 +120,10 @@ class AddFilling(bpy.types.Operator):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
obj = bpy.data.objects.get(self.obj) if self.obj else context.active_object
|
||||
opening = bpy.data.objects.get(self.opening) if self.opening else context.scene.VoidProperties.desired_opening
|
||||
obj = context.scene.objects.get(self.obj, context.active_object)
|
||||
opening = context.scene.objects.get(self.opening, context.scene.VoidProperties.desired_opening)
|
||||
if opening is None:
|
||||
return {'FINISHED'}
|
||||
self.file = IfcStore.get_file()
|
||||
element_id = obj.BIMObjectProperties.ifc_definition_id
|
||||
ifcopenshell.api.run(
|
||||
|
||||
@@ -63,7 +63,7 @@ class Usecase:
|
||||
def get_styled_representation(self, definition_representation):
|
||||
representations = [
|
||||
r
|
||||
for r in definition_representation.Representations is r.is_a("IfcStyledRepresentation")
|
||||
for r in definition_representation.Representations if r.is_a("IfcStyledRepresentation")
|
||||
and r.ContextOfItems == self.settings["context"]
|
||||
]
|
||||
if representations:
|
||||
|
||||
Reference in New Issue
Block a user