Support Add Brick with IfcEntity selected (part 1)

Next is to add the reference
This commit is contained in:
rileywong311
2023-08-14 20:18:18 -07:00
parent ff9903b6a2
commit edb8d636d0
3 changed files with 13 additions and 8 deletions
@@ -131,16 +131,13 @@ class AddBrick(bpy.types.Operator, Operator):
def _execute(self, context):
props = context.scene.BIMBrickProperties
library = None
if props.libraries:
library = tool.Ifc.get().by_id(int(props.libraries))
core.add_brick(
tool.Ifc,
tool.Brick,
element=tool.Ifc.get_entity(context.active_object) if context.selected_objects else None,
namespace=props.namespace,
brick_class=props.brick_entity_class,
library=library,
library=tool.Ifc.get().by_id(int(props.libraries)) if props.libraries else None,
label=props.new_brick_label,
)
@@ -90,8 +90,13 @@ class BIM_PT_brickschema(Panel):
row = self.layout.row(align=True)
row.prop(data=self.props, property="brick_entity_create_type", text="")
# hide this if selected entity already has a reference
row = self.layout.row(align=True)
row.prop(data=self.props, property="new_brick_label", text="")
active = tool.Ifc.get_entity(context.active_object)
if active and context.selected_objects:
row.label(text=active.Name if active.Name else "Unnamed")
else:
row.prop(data=self.props, property="new_brick_label", text="")
prop_with_search(row, self.props, "brick_entity_class", text="")
row.operator("bim.add_brick", text="", icon="ADD")
+6 -3
View File
@@ -67,9 +67,12 @@ class Brick(blenderbim.core.tool.Brick):
def add_brick_from_element(cls, element, namespace, brick_class):
ns = Namespace(namespace)
brick = ns[element.GlobalId]
BrickStore.graph.add((brick, RDF.type, URIRef(brick_class)))
if element.Name:
BrickStore.graph.add((brick, URIRef("http://www.w3.org/2000/01/rdf-schema#label"), Literal(element.Name)))
with BrickStore.new_changeset() as cs:
cs.add((brick, RDF.type, URIRef(brick_class)))
if element.Name:
cs.add((brick, URIRef("http://www.w3.org/2000/01/rdf-schema#label"), Literal(element.Name)))
else:
cs.add((brick, URIRef("http://www.w3.org/2000/01/rdf-schema#label"), Literal("Unnamed")))
return str(brick)
@classmethod