mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-30 08:33:10 +00:00
Merge remote-tracking branch 'origin/v0.7.0' into v08attempt1
This commit is contained in:
@@ -857,7 +857,11 @@ class IfcImporter:
|
||||
print("Done creating geometry")
|
||||
|
||||
def create_spatial_elements(self) -> None:
|
||||
self.create_generic_elements(self.spatial_elements, unselectable=True)
|
||||
if bpy.context.preferences.addons["blenderbim"].preferences.spatial_elements_unselectable:
|
||||
self.create_generic_elements(self.spatial_elements, unselectable=True)
|
||||
else:
|
||||
self.create_generic_elements(self.spatial_elements, unselectable=False)
|
||||
|
||||
|
||||
def create_elements(self) -> None:
|
||||
self.create_generic_elements(self.elements)
|
||||
|
||||
@@ -47,10 +47,18 @@ class EnableEditingAttributes(bpy.types.Operator):
|
||||
obj = bpy.data.objects.get(self.obj)
|
||||
elif self.obj_type == "Material":
|
||||
obj = bpy.data.materials.get(self.obj)
|
||||
oprops = obj.BIMObjectProperties
|
||||
props = obj.BIMAttributeProperties
|
||||
props.attributes.clear()
|
||||
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
has_inherited_predefined_type = False
|
||||
if not element.is_a("IfcTypeObject") and (element_type := ifcopenshell.util.element.get_type(element)):
|
||||
# Allow for None due to https://github.com/buildingSMART/IFC4.3.x-development/issues/818
|
||||
has_inherited_predefined_type = ifcopenshell.util.element.get_predefined_type(element_type) not in (
|
||||
"NOTDEFINED",
|
||||
None,
|
||||
)
|
||||
|
||||
def callback(name, prop, data):
|
||||
if name in ("RefLatitude", "RefLongitude"):
|
||||
new = props.attributes.add()
|
||||
@@ -62,10 +70,11 @@ class EnableEditingAttributes(bpy.types.Operator):
|
||||
new.string_value = "" if new.is_null else json.dumps(data[name])
|
||||
blenderbim.bim.helper.add_attribute_description(new)
|
||||
new.description += " The degrees, minutes and seconds should follow this format : [12,34,56]"
|
||||
if name in ("PredefinedType", "ObjectType") and has_inherited_predefined_type:
|
||||
props.attributes.remove(len(props.attributes) - 1)
|
||||
return True
|
||||
|
||||
blenderbim.bim.helper.import_attributes2(
|
||||
tool.Ifc.get().by_id(oprops.ifc_definition_id), props.attributes, callback=callback
|
||||
)
|
||||
blenderbim.bim.helper.import_attributes2(element, props.attributes, callback=callback)
|
||||
props.is_editing_attributes = True
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ import bpy
|
||||
import json
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.classification
|
||||
import ifcopenshell.util.element
|
||||
import blenderbim.tool as tool
|
||||
import blenderbim.bim.helper
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
@@ -87,7 +89,7 @@ class AddManualClassificationReference(bpy.types.Operator, tool.Ifc.Operator):
|
||||
reference = ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
tool.Ifc.get(),
|
||||
product=product,
|
||||
products=[product],
|
||||
classification=classification,
|
||||
identification="X",
|
||||
name="Unnamed",
|
||||
@@ -292,6 +294,7 @@ class RemoveClassificationReference(bpy.types.Operator, tool.Ifc.Operator):
|
||||
active_reference = tool.Ifc.get().by_id(self.reference)
|
||||
identification = active_reference[1]
|
||||
|
||||
elements_by_references: dict[ifcopenshell.entity_instance, list[ifcopenshell.entity_instance]] = {}
|
||||
for obj in objects:
|
||||
ifc_definition_id = tool.Blender.get_obj_ifc_definition_id(obj, self.obj_type, context)
|
||||
element = tool.Ifc.get().by_id(ifc_definition_id)
|
||||
@@ -300,12 +303,16 @@ class RemoveClassificationReference(bpy.types.Operator, tool.Ifc.Operator):
|
||||
if (identification and reference[1] == identification) or (
|
||||
not identification and reference == active_reference
|
||||
):
|
||||
ifcopenshell.api.run(
|
||||
"classification.remove_reference",
|
||||
tool.Ifc.get(),
|
||||
reference=reference,
|
||||
product=element,
|
||||
)
|
||||
elements_by_references.setdefault(reference, []).append(element)
|
||||
|
||||
if elements_by_references:
|
||||
for reference, products in elements_by_references.items():
|
||||
ifcopenshell.api.run(
|
||||
"classification.remove_reference",
|
||||
tool.Ifc.get(),
|
||||
reference=reference,
|
||||
products=products,
|
||||
)
|
||||
|
||||
|
||||
class EditClassificationReference(bpy.types.Operator, tool.Ifc.Operator):
|
||||
@@ -357,15 +364,18 @@ class AddClassificationReference(bpy.types.Operator, tool.Ifc.Operator):
|
||||
classification = element
|
||||
break
|
||||
|
||||
for obj in objects:
|
||||
ifc_definition_id = tool.Blender.get_obj_ifc_definition_id(obj, self.obj_type, context)
|
||||
if not ifc_definition_id:
|
||||
continue
|
||||
ifc_file = tool.Ifc.get()
|
||||
products = [
|
||||
ifc_file.by_id(ifc_definition_id)
|
||||
for obj in objects
|
||||
if (ifc_definition_id := tool.Blender.get_obj_ifc_definition_id(obj, self.obj_type, context))
|
||||
]
|
||||
if products:
|
||||
ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
tool.Ifc.get(),
|
||||
reference=IfcStore.classification_file.by_id(self.reference),
|
||||
product=tool.Ifc.get().by_id(ifc_definition_id),
|
||||
products=products,
|
||||
classification=classification,
|
||||
)
|
||||
|
||||
@@ -413,7 +423,7 @@ class AddClassificationReferenceFromBSDD(bpy.types.Operator, tool.Ifc.Operator):
|
||||
reference = ifcopenshell.api.run(
|
||||
"classification.add_reference",
|
||||
tool.Ifc.get(),
|
||||
product=element,
|
||||
products=[element],
|
||||
classification=classification,
|
||||
identification=bsdd_classification.reference_code,
|
||||
name=bsdd_classification.name,
|
||||
|
||||
@@ -114,7 +114,7 @@ class EditObjective(bpy.types.Operator):
|
||||
ifcopenshell.api.run(
|
||||
"constraint.edit_objective",
|
||||
self.file,
|
||||
**{"objective": self.file.by_id(props.active_constraint_id), "attributes": attributes}
|
||||
**{"objective": self.file.by_id(props.active_constraint_id), "attributes": attributes},
|
||||
)
|
||||
bpy.ops.bim.load_objectives()
|
||||
return {"FINISHED"}
|
||||
@@ -179,19 +179,17 @@ class AssignConstraint(bpy.types.Operator):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
objs = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects
|
||||
for obj in objs:
|
||||
obj_id = obj.BIMObjectProperties.ifc_definition_id
|
||||
if not obj_id:
|
||||
continue
|
||||
products = [self.file.by_id(obj_id) for obj in objs if (obj_id := obj.BIMObjectProperties.ifc_definition_id)]
|
||||
if products:
|
||||
ifcopenshell.api.run(
|
||||
"constraint.assign_constraint",
|
||||
self.file,
|
||||
**{
|
||||
"product": self.file.by_id(obj_id),
|
||||
"products": products,
|
||||
"constraint": self.file.by_id(self.constraint),
|
||||
}
|
||||
},
|
||||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -207,18 +205,16 @@ class UnassignConstraint(bpy.types.Operator):
|
||||
return IfcStore.execute_ifc_operator(self, context)
|
||||
|
||||
def _execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
self.file = tool.Ifc.get()
|
||||
objs = [bpy.data.objects.get(self.obj)] if self.obj else context.selected_objects
|
||||
for obj in objs:
|
||||
obj_id = obj.BIMObjectProperties.ifc_definition_id
|
||||
if not obj_id:
|
||||
continue
|
||||
products = [self.file.by_id(obj_id) for obj in objs if (obj_id := obj.BIMObjectProperties.ifc_definition_id)]
|
||||
if products:
|
||||
ifcopenshell.api.run(
|
||||
"constraint.unassign_constraint",
|
||||
self.file,
|
||||
**{
|
||||
"product": self.file.by_id(obj_id),
|
||||
"products": products,
|
||||
"constraint": self.file.by_id(self.constraint),
|
||||
}
|
||||
},
|
||||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -2570,8 +2570,16 @@ class EnableEditingElementFilter(bpy.types.Operator, Operator):
|
||||
|
||||
def _execute(self, context):
|
||||
obj = bpy.context.scene.camera
|
||||
if obj:
|
||||
obj.data.BIMCameraProperties.filter_mode = self.filter_mode
|
||||
if not obj:
|
||||
return
|
||||
obj.data.BIMCameraProperties.filter_mode = self.filter_mode
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if query := ifcopenshell.util.element.get_pset(element, "EPset_Drawing", self.filter_mode.title()):
|
||||
filter_groups = tool.Search.get_filter_groups(f"drawing_{self.filter_mode.lower()}")
|
||||
try:
|
||||
tool.Search.import_filter_query(query, filter_groups)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
class EditElementFilter(bpy.types.Operator, Operator):
|
||||
|
||||
@@ -66,6 +66,11 @@ def get_location_hint(self, context):
|
||||
|
||||
|
||||
def update_diagram_scale(self, context):
|
||||
if not context.scene.camera or context.scene.camera.data != self.id_data:
|
||||
return
|
||||
element = tool.Ifc.get_entity(context.scene.camera)
|
||||
if not element:
|
||||
return
|
||||
try:
|
||||
element = (
|
||||
tool.Ifc.get()
|
||||
@@ -87,6 +92,11 @@ def update_diagram_scale(self, context):
|
||||
|
||||
|
||||
def update_is_nts(self, context):
|
||||
if not context.scene.camera or context.scene.camera.data != self.id_data:
|
||||
return
|
||||
element = tool.Ifc.get_entity(context.scene.camera)
|
||||
if not element:
|
||||
return
|
||||
try:
|
||||
element = (
|
||||
tool.Ifc.get()
|
||||
|
||||
@@ -175,7 +175,7 @@ class BIM_PT_object_material(Panel):
|
||||
|
||||
if ObjectMaterialData.data["type_material"]:
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text="Inherited Material: " + ObjectMaterialData.data["type_material"], icon="FILE_PARENT")
|
||||
row.label(text="Inherited Material: " + ObjectMaterialData.data["type_material"], icon="CON_CHILDOF")
|
||||
|
||||
if ObjectMaterialData.data["material_class"]:
|
||||
return self.draw_material_ui()
|
||||
|
||||
@@ -25,6 +25,8 @@ classes = (
|
||||
operator.AppendLibraryElement,
|
||||
operator.AppendLibraryElementByQuery,
|
||||
operator.AssignLibraryDeclaration,
|
||||
operator.BIM_OT_load_clipping_planes,
|
||||
operator.BIM_OT_save_clipping_planes,
|
||||
operator.ChangeLibraryElement,
|
||||
operator.CreateClippingPlane,
|
||||
operator.CreateProject,
|
||||
|
||||
@@ -39,6 +39,8 @@ from blenderbim.bim.ifc import IfcStore
|
||||
from blenderbim.bim.ui import IFCFileSelector
|
||||
from blenderbim.bim import import_ifc
|
||||
from blenderbim.bim import export_ifc
|
||||
from collections import defaultdict
|
||||
import json
|
||||
from math import radians
|
||||
from pathlib import Path
|
||||
from mathutils import Vector, Matrix
|
||||
@@ -1999,3 +2001,61 @@ class FlipClippingPlane(bpy.types.Operator):
|
||||
obj.rotation_euler[0] += radians(180)
|
||||
context.view_layer.update()
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
CLIPPING_PLANES_FILE_NAME = "ClippingPlanes.json" # TODO un-hardcode :=
|
||||
|
||||
|
||||
class BIM_OT_save_clipping_planes(bpy.types.Operator):
|
||||
bl_idname = "bim.save_clipping_planes"
|
||||
bl_label = "Save Clipping Planes"
|
||||
bl_description = "Save Clipping Planes to Disk"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
if IfcStore.path:
|
||||
return context.scene.BIMProjectProperties.clipping_planes
|
||||
cls.poll_message_set("Please Save The IFC File")
|
||||
|
||||
def execute(self, context):
|
||||
clipping_planes_to_serialize = defaultdict(dict)
|
||||
clipping_planes = context.scene.BIMProjectProperties.clipping_planes
|
||||
for clipping_plane in clipping_planes:
|
||||
obj = clipping_plane.obj
|
||||
name = obj.name
|
||||
clipping_planes_to_serialize[name]["location"] = obj.location[0:3]
|
||||
clipping_planes_to_serialize[name]["rotation"] = obj.rotation_euler[0:3]
|
||||
with open(Path(IfcStore.path).with_name(CLIPPING_PLANES_FILE_NAME), "w") as file:
|
||||
json.dump(clipping_planes_to_serialize, file, indent=4)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class BIM_OT_load_clipping_planes(bpy.types.Operator):
|
||||
bl_idname = "bim.load_clipping_planes"
|
||||
bl_label = "Load Clipping Planes"
|
||||
bl_description = "Load Clipping Planes from Disk"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
if filepath := IfcStore.path:
|
||||
if Path(filepath).with_name(CLIPPING_PLANES_FILE_NAME).exists():
|
||||
return True
|
||||
else:
|
||||
cls.poll_message_set(f"No Clipping Planes File in Folder {filepath}")
|
||||
else:
|
||||
cls.poll_message_set("Please Save The IFC File")
|
||||
|
||||
def execute(self, context):
|
||||
bpy.data.batch_remove(context.scene.BIMProjectProperties.clipping_planes_objs)
|
||||
context.scene.BIMProjectProperties.clipping_planes.clear()
|
||||
with open(Path(IfcStore.path).with_name(CLIPPING_PLANES_FILE_NAME), "r") as file:
|
||||
clipping_planes_dict = json.load(file)
|
||||
for name, values in clipping_planes_dict.items():
|
||||
bpy.ops.bim.create_clipping_plane()
|
||||
obj = context.scene.BIMProjectProperties.clipping_planes_objs[-1]
|
||||
obj.name = name
|
||||
obj.location = values["location"]
|
||||
obj.rotation_euler = values["rotation"]
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -69,6 +69,7 @@ class ObjectPsetsData(Data):
|
||||
@classmethod
|
||||
def load(cls):
|
||||
cls.data = {
|
||||
"is_occurrence": cls.is_occurrence(),
|
||||
"psets": cls.psetqtos(tool.Ifc.get_entity(bpy.context.active_object), psets_only=True),
|
||||
"inherited_psets": cls.inherited_psets(),
|
||||
"pset_name": cls.pset_name(),
|
||||
@@ -76,6 +77,10 @@ class ObjectPsetsData(Data):
|
||||
}
|
||||
cls.is_loaded = True
|
||||
|
||||
@classmethod
|
||||
def is_occurrence(cls):
|
||||
return not tool.Ifc.get_entity(bpy.context.active_object).is_a("IfcTypeObject")
|
||||
|
||||
@classmethod
|
||||
def inherited_psets(cls):
|
||||
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||
@@ -126,11 +131,16 @@ class ObjectQtosData(Data):
|
||||
@classmethod
|
||||
def load(cls):
|
||||
cls.data = {
|
||||
"is_occurrence": cls.is_occurrence(),
|
||||
"qtos": cls.psetqtos(tool.Ifc.get_entity(bpy.context.active_object), qtos_only=True),
|
||||
"inherited_qsets": cls.inherited_qsets(),
|
||||
}
|
||||
cls.is_loaded = True
|
||||
|
||||
@classmethod
|
||||
def is_occurrence(cls):
|
||||
return not tool.Ifc.get_entity(bpy.context.active_object).is_a("IfcTypeObject")
|
||||
|
||||
@classmethod
|
||||
def inherited_qsets(cls):
|
||||
element = tool.Ifc.get_entity(bpy.context.active_object)
|
||||
|
||||
@@ -208,12 +208,15 @@ class BIM_PT_object_psets(Panel):
|
||||
draw_psetqto_ui(context, 0, {}, props, self.layout, "Object")
|
||||
|
||||
if ObjectPsetsData.data["psets"]:
|
||||
self.layout.label(text="Instance:")
|
||||
if ObjectPsetsData.data["is_occurrence"]:
|
||||
self.layout.label(text="Occurrence Properties:")
|
||||
else:
|
||||
self.layout.label(text="Type Properties:")
|
||||
for pset in ObjectPsetsData.data["psets"]:
|
||||
draw_psetqto_ui(context, pset["id"], pset, props, self.layout, "Object")
|
||||
|
||||
if ObjectPsetsData.data["inherited_psets"]:
|
||||
self.layout.label(text="Type:")
|
||||
self.layout.label(text="Inherited Type Properties:", icon="CON_CHILDOF")
|
||||
for pset in ObjectPsetsData.data["inherited_psets"]:
|
||||
draw_psetqto_ui(context, pset["id"], pset, props, self.layout, "Object", allow_removing=False)
|
||||
|
||||
@@ -252,12 +255,15 @@ class BIM_PT_object_qtos(Panel):
|
||||
draw_psetqto_ui(context, 0, {}, props, self.layout, "Object")
|
||||
|
||||
if ObjectQtosData.data["qtos"]:
|
||||
self.layout.label(text="Instance:")
|
||||
if ObjectQtosData.data["is_occurrence"]:
|
||||
self.layout.label(text="Occurrence Quantities:")
|
||||
else:
|
||||
self.layout.label(text="Type Quantities:")
|
||||
for qto in ObjectQtosData.data["qtos"]:
|
||||
draw_psetqto_ui(context, qto["id"], qto, props, self.layout, "Object")
|
||||
|
||||
if ObjectQtosData.data["inherited_qsets"]:
|
||||
self.layout.label(text="Type:")
|
||||
self.layout.label(text="Inherited Type Quantities:", icon="CON_CHILDOF")
|
||||
for qset in ObjectQtosData.data["inherited_qsets"]:
|
||||
draw_psetqto_ui(context, qset["id"], qset, props, self.layout, "Object", allow_removing=False)
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ class IfcClassData:
|
||||
cls.data["contexts"] = cls.contexts()
|
||||
cls.data["has_entity"] = cls.has_entity()
|
||||
cls.data["name"] = cls.name()
|
||||
cls.data["has_inherited_predefined_type"] = cls.has_inherited_predefined_type()
|
||||
cls.data["ifc_class"] = cls.ifc_class()
|
||||
cls.data["ifc_predefined_types"] = cls.ifc_predefined_types()
|
||||
cls.data["can_reassign_class"] = cls.can_reassign_class()
|
||||
@@ -162,6 +163,16 @@ class IfcClassData:
|
||||
name += f"[{predefined_type}]"
|
||||
return name
|
||||
|
||||
@classmethod
|
||||
def has_inherited_predefined_type(cls):
|
||||
element = tool.Ifc.get_entity(bpy.context.view_layer.objects.active)
|
||||
if not element:
|
||||
return
|
||||
if element_type := ifcopenshell.util.element.get_type(element):
|
||||
# Allow for None due to https://github.com/buildingSMART/IFC4.3.x-development/issues/818
|
||||
return ifcopenshell.util.element.get_predefined_type(element_type) not in ("NOTDEFINED", None)
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def ifc_class(cls):
|
||||
element = tool.Ifc.get_entity(bpy.context.view_layer.objects.active)
|
||||
|
||||
@@ -61,7 +61,10 @@ class BIM_PT_class(Panel):
|
||||
self.layout.prop(context.scene.BIMRootProperties, "relating_class_object", icon="COPYDOWN")
|
||||
else:
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text=IfcClassData.data["name"])
|
||||
row.label(
|
||||
text=IfcClassData.data["name"],
|
||||
icon="CON_CHILDOF" if IfcClassData.data["has_inherited_predefined_type"] else "NONE",
|
||||
)
|
||||
row.operator("bim.select_ifc_class", text="", icon="RESTRICT_SELECT_OFF")
|
||||
row.operator("bim.unlink_object", icon="UNLINKED", text="")
|
||||
if IfcClassData.data["can_reassign_class"]:
|
||||
|
||||
@@ -235,7 +235,7 @@ class LoadSearch(Operator, tool.Ifc.Operator):
|
||||
def _execute(self, context):
|
||||
filter_groups = tool.Search.get_filter_groups(self.module)
|
||||
group = tool.Ifc.get().by_id(int(context.scene.BIMSearchProperties.saved_searches))
|
||||
query = tool.Search.import_filter_query(tool.Search.get_group_query(group), filter_groups)
|
||||
tool.Search.import_filter_query(tool.Search.get_group_query(group), filter_groups)
|
||||
|
||||
def draw(self, context):
|
||||
props = context.scene.BIMSearchProperties
|
||||
|
||||
@@ -131,6 +131,8 @@ class BIM_PT_section_with_cappings(Panel):
|
||||
box = layout.box()
|
||||
header = box.row(align=True)
|
||||
header.label(text="Clipping Planes")
|
||||
header.operator("bim.save_clipping_planes", text="", icon="EXPORT")
|
||||
header.operator("bim.load_clipping_planes", text="", icon="IMPORT")
|
||||
header.operator("bim.create_clipping_plane", text="", icon="ADD")
|
||||
|
||||
box.template_list(
|
||||
@@ -150,7 +152,7 @@ class BIM_PT_section_with_cappings(Panel):
|
||||
|
||||
class BIM_UL_clipping_plane(bpy.types.UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
if item:
|
||||
if item and item.obj:
|
||||
obj = item.obj
|
||||
row = layout.row(align=True)
|
||||
row.prop(obj, "name", text="", emboss=False)
|
||||
@@ -202,6 +204,7 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||
name="Should Make A Cha-Ching Sound When Project Costs Updates", default=False
|
||||
)
|
||||
lock_grids_on_import: BoolProperty(name="Should Lock Grids By Default", default=True)
|
||||
spatial_elements_unselectable: BoolProperty(name="Should Make Spatial Elements Unselectable By Default", default=True)
|
||||
decorations_colour: bpy.props.FloatVectorProperty(
|
||||
name="Decorations Colour", subtype="COLOR", default=(1, 1, 1, 1), min=0.0, max=1.0, size=4
|
||||
)
|
||||
@@ -283,6 +286,10 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||
row.prop(self, "should_play_chaching_sound")
|
||||
row = layout.row()
|
||||
row.prop(self, "lock_grids_on_import")
|
||||
row = layout.row()
|
||||
row.prop(self, "spatial_elements_unselectable")
|
||||
|
||||
|
||||
|
||||
row = layout.row()
|
||||
row.prop(context.scene.BIMProjectProperties, "should_disable_undo_on_save")
|
||||
|
||||
@@ -74,7 +74,7 @@ def assign_brick_reference(ifc, brick, element=None, library=None, brick_uri=Non
|
||||
if not reference:
|
||||
reference = ifc.run("library.add_reference", library=library)
|
||||
ifc.run("library.edit_reference", reference=reference, attributes=brick.export_brick_attributes(brick_uri))
|
||||
ifc.run("library.assign_reference", product=element, reference=reference)
|
||||
ifc.run("library.assign_reference", products=[element], reference=reference)
|
||||
project = brick.get_brickifc_project()
|
||||
if not project:
|
||||
project = brick.add_brickifc_project(brick.get_namespace(brick_uri))
|
||||
|
||||
@@ -109,8 +109,8 @@ def remove_document(ifc, document_tool, document=None):
|
||||
|
||||
|
||||
def assign_document(ifc, product=None, document=None):
|
||||
ifc.run("document.assign_document", product=product, document=document)
|
||||
ifc.run("document.assign_document", products=[product], document=document)
|
||||
|
||||
|
||||
def unassign_document(ifc, product=None, document=None):
|
||||
ifc.run("document.unassign_document", product=product, document=document)
|
||||
ifc.run("document.unassign_document", products=[product], document=document)
|
||||
|
||||
@@ -241,7 +241,7 @@ def add_drawing(ifc, collector, drawing, target_view=None, location_hint=None):
|
||||
attributes = {"Identification": "X", "Name": drawing_name, "Scope": "DRAWING"}
|
||||
ifc.run("document.edit_information", information=information, attributes=attributes)
|
||||
ifc.run("document.edit_reference", reference=reference, attributes={"Location": uri})
|
||||
ifc.run("document.assign_document", product=element, document=reference)
|
||||
ifc.run("document.assign_document", products=[element], document=reference)
|
||||
drawing.import_drawings()
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ def duplicate_drawing(ifc, drawing_tool, drawing=None, should_duplicate_annotati
|
||||
ifc.run("group.assign_group", group=new_group, products=[new_annotation])
|
||||
|
||||
old_reference = drawing_tool.get_drawing_document(new_drawing)
|
||||
ifc.run("document.unassign_document", product=new_drawing, document=old_reference)
|
||||
ifc.run("document.unassign_document", products=[new_drawing], document=old_reference)
|
||||
|
||||
information = ifc.run("document.add_information")
|
||||
uri = drawing_tool.get_default_drawing_path(drawing_name)
|
||||
@@ -276,7 +276,7 @@ def duplicate_drawing(ifc, drawing_tool, drawing=None, should_duplicate_annotati
|
||||
attributes = {"Identification": "X", "Name": drawing_name, "Scope": "DRAWING"}
|
||||
ifc.run("document.edit_information", information=information, attributes=attributes)
|
||||
ifc.run("document.edit_reference", reference=reference, attributes={"Location": uri})
|
||||
ifc.run("document.assign_document", product=new_drawing, document=reference)
|
||||
ifc.run("document.assign_document", products=[new_drawing], document=reference)
|
||||
|
||||
drawing_tool.import_drawings()
|
||||
return new_drawing
|
||||
|
||||
@@ -83,8 +83,8 @@ def edit_library_reference(ifc, library):
|
||||
|
||||
|
||||
def assign_library_reference(ifc, obj=None, reference=None):
|
||||
ifc.run("library.assign_reference", product=ifc.get_entity(obj), reference=reference)
|
||||
ifc.run("library.assign_reference", products=[ifc.get_entity(obj)], reference=reference)
|
||||
|
||||
|
||||
def unassign_library_reference(ifc, obj=None, reference=None):
|
||||
ifc.run("library.unassign_reference", product=ifc.get_entity(obj), reference=reference)
|
||||
ifc.run("library.unassign_reference", products=[ifc.get_entity(obj)], reference=reference)
|
||||
|
||||
@@ -195,7 +195,7 @@ def add_usage_constraint(ifc, resource_tool, resource=None, reference_path=None)
|
||||
},
|
||||
)
|
||||
ifc.run("constraint.add_metric_reference", metric=metric, reference_path=reference_path)
|
||||
ifc.run("constraint.assign_constraint", product=resource, constraint=objective)
|
||||
ifc.run("constraint.assign_constraint", products=[resource], constraint=objective)
|
||||
|
||||
|
||||
def remove_usage_constraint(ifc, resource_tool, resource, reference_path):
|
||||
@@ -206,7 +206,7 @@ def remove_usage_constraint(ifc, resource_tool, resource, reference_path):
|
||||
reference = resource_tool.get_metric_reference(metric, is_deep=True)
|
||||
if reference == reference_path:
|
||||
ifc.run("constraint.remove_metric", metric=metric)
|
||||
ifc.run("constraint.unassign_constraint", product=resource, constraint=constraint)
|
||||
ifc.run("constraint.unassign_constraint", products=[resource], constraint=constraint)
|
||||
ifc.run("constraint.remove_constraint", constraint=constraint)
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ def reference_structure(
|
||||
element: Optional[ifcopenshell.entity_instance] = None,
|
||||
) -> Union[ifcopenshell.entity_instance, None]:
|
||||
if spatial.can_reference(structure, element):
|
||||
return ifc.run("spatial.reference_structure", product=element, relating_structure=structure)
|
||||
return ifc.run("spatial.reference_structure", products=[element], relating_structure=structure)
|
||||
|
||||
|
||||
def dereference_structure(
|
||||
@@ -42,7 +42,7 @@ def dereference_structure(
|
||||
element: Optional[ifcopenshell.entity_instance] = None,
|
||||
) -> None:
|
||||
if spatial.can_reference(structure, element):
|
||||
return ifc.run("spatial.dereference_structure", product=element, relating_structure=structure)
|
||||
return ifc.run("spatial.dereference_structure", products=[element], relating_structure=structure)
|
||||
|
||||
|
||||
def assign_container(
|
||||
|
||||
@@ -733,7 +733,6 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
|
||||
obj.BIMObjectProperties.ifc_definition_id = ifc_definition_id
|
||||
|
||||
|
||||
@classmethod
|
||||
def import_drawings(cls):
|
||||
props = bpy.context.scene.DocProperties
|
||||
@@ -1776,7 +1775,6 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
element_obj_names = set()
|
||||
for element in filtered_elements:
|
||||
obj = tool.Ifc.get_object(element)
|
||||
element_obj_names.add(obj.name)
|
||||
current_representation = tool.Geometry.get_active_representation(obj)
|
||||
if current_representation:
|
||||
subcontext = current_representation.ContextOfItems
|
||||
@@ -1805,10 +1803,14 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
|
||||
# Don't hide IfcAnnotations as some of them might exist without representations
|
||||
if has_context or element.is_a("IfcAnnotation"):
|
||||
# Note that render visibility is only set on drawing generation time for speed.
|
||||
obj.hide_set(False)
|
||||
element_obj_names.add(obj.name)
|
||||
|
||||
[obj.hide_set(False) for obj in bpy.context.view_layer.objects if obj.name not in element_obj_names]
|
||||
# Note that render visibility is only set on drawing generation time for speed.
|
||||
[
|
||||
obj.hide_set(False) # Show the object
|
||||
for obj in bpy.context.view_layer.objects
|
||||
if obj.name in element_obj_names or not tool.Ifc.get_entity(obj)
|
||||
]
|
||||
|
||||
cls.import_camera_props(drawing, camera)
|
||||
|
||||
|
||||
@@ -91,6 +91,17 @@ class Geometry(blenderbim.core.tool.Geometry):
|
||||
if element.is_a("IfcRelSpaceBoundary"):
|
||||
ifcopenshell.api.run("boundary.remove_boundary", tool.Ifc.get(), boundary=element)
|
||||
return bpy.data.objects.remove(obj)
|
||||
if element.is_a("IfcGridAxis"):
|
||||
is_last_axis = False
|
||||
# Deleting the last W axis is OK
|
||||
if ((grid := element.PartOfU) and len(grid[0].UAxes) == 1) or (
|
||||
(grid := element.PartOfV) and len(grid[0].VAxes) == 1
|
||||
):
|
||||
is_last_axis = True
|
||||
if is_last_axis:
|
||||
return
|
||||
ifcopenshell.api.run("grid.remove_grid_axis", tool.Ifc.get(), axis=element)
|
||||
return bpy.data.objects.remove(obj)
|
||||
|
||||
collection = obj.BIMObjectProperties.collection
|
||||
if collection:
|
||||
|
||||
@@ -29,7 +29,9 @@ Some of these add-ons are not shipped with Blender:
|
||||
- `Sverchok <https://github.com/nortikin/sverchok/>`__ - Sverchok is a visual
|
||||
programming add-on for Blender that allows you to generate parametric
|
||||
geometry, create scripts for non-programmers, model solids from FreeCAD, and
|
||||
much more.
|
||||
much more. There is also
|
||||
`IfcSverchok <https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcsverchok/README.md/>`__
|
||||
that adds IFC features to Sverchok.
|
||||
- `BlenderGIS <https://github.com/domlysz/BlenderGIS>`__ - BlenderGIS lets you
|
||||
import GIS data, grab elevation data from the web, and generate TINs from
|
||||
survey points and contours.
|
||||
|
||||
@@ -124,21 +124,21 @@ class TestAssignBrickReference:
|
||||
ifc.run("library.add_reference", library="library").should_be_called().will_return("reference")
|
||||
brick.export_brick_attributes("brick_uri").should_be_called().will_return("attributes")
|
||||
ifc.run("library.edit_reference", reference="reference", attributes="attributes").should_be_called()
|
||||
ifc.run("library.assign_reference", product="element", reference="reference").should_be_called()
|
||||
ifc.run("library.assign_reference", products=["element"], reference="reference").should_be_called()
|
||||
brick.get_brickifc_project().should_be_called().will_return("project")
|
||||
brick.add_brickifc_reference("brick_uri", "element", "project").should_be_called()
|
||||
subject.assign_brick_reference(ifc, brick, element="element", library="library", brick_uri="brick_uri")
|
||||
|
||||
def test_assigning_to_an_existing_reference(self, ifc, brick):
|
||||
brick.get_library_brick_reference("library", "brick_uri").should_be_called().will_return("reference")
|
||||
ifc.run("library.assign_reference", product="element", reference="reference").should_be_called()
|
||||
ifc.run("library.assign_reference", products=["element"], reference="reference").should_be_called()
|
||||
brick.get_brickifc_project().should_be_called().will_return("project")
|
||||
brick.add_brickifc_reference("brick_uri", "element", "project").should_be_called()
|
||||
subject.assign_brick_reference(ifc, brick, element="element", library="library", brick_uri="brick_uri")
|
||||
|
||||
def test_adding_a_brickifc_project_if_it_doesnt_exist(self, ifc, brick):
|
||||
brick.get_library_brick_reference("library", "brick_uri").should_be_called().will_return("reference")
|
||||
ifc.run("library.assign_reference", product="element", reference="reference").should_be_called()
|
||||
ifc.run("library.assign_reference", products=["element"], reference="reference").should_be_called()
|
||||
brick.get_brickifc_project().should_be_called().will_return(None)
|
||||
brick.get_namespace("brick_uri").should_be_called().will_return("namespace")
|
||||
brick.add_brickifc_project("namespace").should_be_called().will_return("project")
|
||||
@@ -277,4 +277,4 @@ class TestSetBrickListRoot:
|
||||
class TestRemoveBrickRelation:
|
||||
def test_run(self, brick):
|
||||
brick.remove_relation("brick_uri", "predicate", "object").should_be_called()
|
||||
subject.remove_brick_relation(brick, brick_uri="brick_uri", predicate="predicate", object="object")
|
||||
subject.remove_brick_relation(brick, brick_uri="brick_uri", predicate="predicate", object="object")
|
||||
|
||||
@@ -133,11 +133,11 @@ class TestRemoveDocument:
|
||||
|
||||
class TestAssignDocument:
|
||||
def test_run(self, ifc):
|
||||
ifc.run("document.assign_document", product="product", document="document").should_be_called()
|
||||
ifc.run("document.assign_document", products=["product"], document="document").should_be_called()
|
||||
subject.assign_document(ifc, product="product", document="document")
|
||||
|
||||
|
||||
class TestUnassignDocument:
|
||||
def test_run(self, ifc):
|
||||
ifc.run("document.unassign_document", product="product", document="document").should_be_called()
|
||||
ifc.run("document.unassign_document", products=["product"], document="document").should_be_called()
|
||||
subject.unassign_document(ifc, product="product", document="document")
|
||||
|
||||
@@ -365,7 +365,7 @@ class TestAddDrawing:
|
||||
attributes={"Identification": "X", "Name": "name", "Scope": "DRAWING"},
|
||||
).should_be_called()
|
||||
ifc.run("document.edit_reference", reference="reference", attributes={"Location": "uri"}).should_be_called()
|
||||
ifc.run("document.assign_document", product="element", document="reference").should_be_called()
|
||||
ifc.run("document.assign_document", products=["element"], document="reference").should_be_called()
|
||||
drawing.import_drawings().should_be_called()
|
||||
subject.add_drawing(ifc, collector, drawing, target_view="target_view", location_hint="location_hint")
|
||||
|
||||
@@ -391,7 +391,7 @@ class TestDuplicateDrawing:
|
||||
ifc.run("group.assign_group", group="new_group", products=["new_annotation"]).should_be_called()
|
||||
|
||||
drawing.get_drawing_document("new_drawing").should_be_called().will_return("old_reference")
|
||||
ifc.run("document.unassign_document", product="new_drawing", document="old_reference").should_be_called()
|
||||
ifc.run("document.unassign_document", products=["new_drawing"], document="old_reference").should_be_called()
|
||||
|
||||
ifc.run("document.add_information").should_be_called().will_return("information")
|
||||
ifc.run("document.add_reference", information="information").should_be_called().will_return("reference")
|
||||
@@ -405,7 +405,7 @@ class TestDuplicateDrawing:
|
||||
ifc.run(
|
||||
"document.edit_reference", reference="reference", attributes={"Location": "drawing_path"}
|
||||
).should_be_called()
|
||||
ifc.run("document.assign_document", product="new_drawing", document="reference").should_be_called()
|
||||
ifc.run("document.assign_document", products=["new_drawing"], document="reference").should_be_called()
|
||||
|
||||
drawing.import_drawings().should_be_called()
|
||||
subject.duplicate_drawing(ifc, drawing, drawing="drawing", should_duplicate_annotations=True)
|
||||
|
||||
@@ -114,12 +114,12 @@ class TestEditLibraryReference:
|
||||
class TestAssignLibraryReference:
|
||||
def test_run(self, ifc):
|
||||
ifc.get_entity("obj").should_be_called().will_return("product")
|
||||
ifc.run("library.assign_reference", product="product", reference="reference").should_be_called()
|
||||
ifc.run("library.assign_reference", products=["product"], reference="reference").should_be_called()
|
||||
subject.assign_library_reference(ifc, obj="obj", reference="reference")
|
||||
|
||||
|
||||
class TestUnassignLibraryReference:
|
||||
def test_run(self, ifc):
|
||||
ifc.get_entity("obj").should_be_called().will_return("product")
|
||||
ifc.run("library.unassign_reference", product="product", reference="reference").should_be_called()
|
||||
ifc.run("library.unassign_reference", products=["product"], reference="reference").should_be_called()
|
||||
subject.unassign_library_reference(ifc, obj="obj", reference="reference")
|
||||
|
||||
@@ -23,14 +23,14 @@ from test.core.bootstrap import ifc, collector, spatial
|
||||
class TestReferenceStructure:
|
||||
def test_run(self, ifc, spatial):
|
||||
spatial.can_reference("structure", "element").should_be_called().will_return(True)
|
||||
ifc.run("spatial.reference_structure", product="element", relating_structure="structure").should_be_called()
|
||||
ifc.run("spatial.reference_structure", products=["element"], relating_structure="structure").should_be_called()
|
||||
subject.reference_structure(ifc, spatial, structure="structure", element="element")
|
||||
|
||||
|
||||
class TestDereferenceStructure:
|
||||
def test_run(self, ifc, spatial):
|
||||
spatial.can_reference("structure", "element").should_be_called().will_return(True)
|
||||
ifc.run("spatial.dereference_structure", product="element", relating_structure="structure").should_be_called()
|
||||
ifc.run("spatial.dereference_structure", products=["element"], relating_structure="structure").should_be_called()
|
||||
subject.dereference_structure(ifc, spatial, structure="structure", element="element")
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import blenderbim.core.tool
|
||||
import blenderbim.tool as tool
|
||||
from test.bim.bootstrap import NewFile
|
||||
@@ -188,7 +189,7 @@ class TestImportReferences(NewFile):
|
||||
assert len(props.documents) == 1
|
||||
assert props.documents[0].ifc_definition_id == reference.id()
|
||||
assert props.documents[0].name == "Unnamed"
|
||||
assert props.documents[0].identification == "*"
|
||||
assert props.documents[0].identification == "X"
|
||||
assert props.documents[0].is_information is False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user