mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
Consolidate adding alignments into Add Element interface
This commit is contained in:
@@ -82,6 +82,8 @@ class IfcClassData:
|
|||||||
feature_elements = ifcopenshell.util.schema.get_subtypes(entity)
|
feature_elements = ifcopenshell.util.schema.get_subtypes(entity)
|
||||||
for feature_element in feature_elements:
|
for feature_element in feature_elements:
|
||||||
names.remove(feature_element.name())
|
names.remove(feature_element.name())
|
||||||
|
if ifc_product == "IfcAlignment":
|
||||||
|
names.extend(("IfcAlignmentHorizontal", "IfcAlignmentHorizontal", "IfcAlignmentCant"))
|
||||||
version = tool.Ifc.get_schema()
|
version = tool.Ifc.get_schema()
|
||||||
return [(c, c, (get_entity_doc(version, c) or {}).get("description", "")) for c in sorted(names)]
|
return [(c, c, (get_entity_doc(version, c) or {}).get("description", "")) for c in sorted(names)]
|
||||||
|
|
||||||
@@ -136,7 +138,9 @@ class IfcClassData:
|
|||||||
("EMPTY", "No Geometry", "Start with an empty object"),
|
("EMPTY", "No Geometry", "Start with an empty object"),
|
||||||
]
|
]
|
||||||
|
|
||||||
if ifc_class in ("IfcWindowType", "IfcWindowStyle", "IfcWindow"):
|
if ifc_class == "IfcAlignment":
|
||||||
|
return templates
|
||||||
|
elif ifc_class in ("IfcWindowType", "IfcWindowStyle", "IfcWindow"):
|
||||||
templates.extend([None, ("WINDOW", "Window", "Parametric window")])
|
templates.extend([None, ("WINDOW", "Window", "Parametric window")])
|
||||||
elif ifc_class in ("IfcDoorType", "IfcDoorStyle", "IfcDoor"):
|
elif ifc_class in ("IfcDoorType", "IfcDoorStyle", "IfcDoor"):
|
||||||
templates.extend([None, ("DOOR", "Door", "Parametric door")])
|
templates.extend([None, ("DOOR", "Door", "Parametric door")])
|
||||||
|
|||||||
@@ -531,6 +531,9 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
if props.ifc_product == "IfcFeatureElement" and not props.featured_obj:
|
if props.ifc_product == "IfcFeatureElement" and not props.featured_obj:
|
||||||
return self.report({"WARNING"}, "A featured element must be nominated.")
|
return self.report({"WARNING"}, "A featured element must be nominated.")
|
||||||
|
|
||||||
|
if "Alignment" in props.ifc_product and props.ifc_product != "IfcAlignment" and not props.featured_obj:
|
||||||
|
return self.report({"WARNING"}, "A parent alignment element must be nominated.")
|
||||||
|
|
||||||
ifc_context = None
|
ifc_context = None
|
||||||
if get_enum_items(props, "contexts", context):
|
if get_enum_items(props, "contexts", context):
|
||||||
ifc_context = int(props.contexts or "0") or None
|
ifc_context = int(props.contexts or "0") or None
|
||||||
@@ -821,6 +824,13 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
tool.Model.purge_scene_openings()
|
tool.Model.purge_scene_openings()
|
||||||
tool.Collector.assign(obj)
|
tool.Collector.assign(obj)
|
||||||
|
|
||||||
|
if props.featured_obj:
|
||||||
|
alignment = tool.Ifc.get_entity(props.featured_obj)
|
||||||
|
if props.ifc_class == "IfcAlignment":
|
||||||
|
ifcopenshell.api.aggregate.assign_object(tool.Ifc.get(), products=[element], relating_object=alignment)
|
||||||
|
elif props.ifc_class in ("IfcAlignmentHorizontal", "IfcAlignmentVertical", "IfcAlignmentCant"):
|
||||||
|
ifcopenshell.api.nest.assign_object(tool.Ifc.get(), related_objects=[element], relating_object=alignment)
|
||||||
|
|
||||||
bonsai.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
|
bonsai.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=obj)
|
||||||
tool.Blender.set_active_object(obj)
|
tool.Blender.set_active_object(obj)
|
||||||
|
|
||||||
@@ -842,7 +852,7 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
if props.ifc_predefined_type == "USERDEFINED":
|
if props.ifc_predefined_type == "USERDEFINED":
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.prop(props, "ifc_userdefined_type")
|
row.prop(props, "ifc_userdefined_type")
|
||||||
if props.ifc_product == "IfcFeatureElement":
|
if props.ifc_product in ("IfcFeatureElement", "IfcAlignment"):
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.prop(props, "featured_obj", text="Featured Object")
|
row.prop(props, "featured_obj", text="Featured Object")
|
||||||
prop_with_search(self.layout, props, "representation_template", text="Representation", should_click_ok=True)
|
prop_with_search(self.layout, props, "representation_template", text="Representation", should_click_ok=True)
|
||||||
|
|||||||
@@ -474,10 +474,10 @@ class Root(bonsai.core.tool.Root):
|
|||||||
obj.name = obj.name.split("/", 1)[1]
|
obj.name = obj.name.split("/", 1)[1]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_ifc_products(cls) -> tuple[str, ...]:
|
def get_ifc_products(cls) -> list[str]:
|
||||||
version = tool.Ifc.get_schema()
|
version = tool.Ifc.get_schema()
|
||||||
if version == "IFC2X3":
|
if version == "IFC2X3":
|
||||||
products = (
|
return [
|
||||||
"IfcElementType",
|
"IfcElementType",
|
||||||
"IfcElement",
|
"IfcElement",
|
||||||
"IfcFeatureElement",
|
"IfcFeatureElement",
|
||||||
@@ -485,16 +485,17 @@ class Root(bonsai.core.tool.Root):
|
|||||||
"IfcStructuralItem",
|
"IfcStructuralItem",
|
||||||
"IfcAnnotation",
|
"IfcAnnotation",
|
||||||
"IfcRelSpaceBoundary",
|
"IfcRelSpaceBoundary",
|
||||||
)
|
]
|
||||||
else:
|
products = [
|
||||||
products = (
|
"IfcElementType",
|
||||||
"IfcElementType",
|
"IfcElement",
|
||||||
"IfcElement",
|
"IfcFeatureElement",
|
||||||
"IfcFeatureElement",
|
"IfcSpatialElement",
|
||||||
"IfcSpatialElement",
|
"IfcSpatialElementType",
|
||||||
"IfcSpatialElementType",
|
"IfcStructuralItem",
|
||||||
"IfcStructuralItem",
|
"IfcAnnotation",
|
||||||
"IfcAnnotation",
|
"IfcRelSpaceBoundary",
|
||||||
"IfcRelSpaceBoundary",
|
]
|
||||||
)
|
if version != "IFC4":
|
||||||
|
products.append("IfcAlignment")
|
||||||
return products
|
return products
|
||||||
|
|||||||
Reference in New Issue
Block a user