mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Add brick operator accepts label parameter & add toggle for namespace editing
This commit is contained in:
@@ -36,6 +36,7 @@ classes = (
|
||||
operator.UndoBrick,
|
||||
operator.RedoBrick,
|
||||
operator.SerializeBrick,
|
||||
operator.AddBrickNamespace,
|
||||
prop.Brick,
|
||||
prop.BIMBrickProperties,
|
||||
ui.BIM_PT_brickschema,
|
||||
|
||||
@@ -126,6 +126,7 @@ class AddBrick(bpy.types.Operator, Operator):
|
||||
namespace=props.namespace,
|
||||
brick_class=props.brick_equipment_class,
|
||||
library=library,
|
||||
label=props.new_brick_label
|
||||
)
|
||||
|
||||
|
||||
@@ -229,4 +230,14 @@ class SerializeBrick(bpy.types.Operator, Operator):
|
||||
def description(cls, context, properties):
|
||||
if properties.should_save_as:
|
||||
return "Save Brick project to a selected file"
|
||||
return "Save the Brick project"
|
||||
return "Save the Brick project"
|
||||
|
||||
class AddBrickNamespace(bpy.types.Operator, Operator):
|
||||
bl_idname = "bim.add_brick_namespace"
|
||||
bl_label = "Add Brick Namespace"
|
||||
|
||||
def _execute(self, context):
|
||||
props = context.scene.BIMBrickProperties
|
||||
alias = props.new_brick_namespace_alias
|
||||
uri = props.new_brick_namespace_uri
|
||||
core.add_namespace(tool.Brick, alias=alias, uri=uri)
|
||||
@@ -30,6 +30,7 @@ from bpy.props import (
|
||||
FloatVectorProperty,
|
||||
CollectionProperty,
|
||||
)
|
||||
from blenderbim.tool.brick import BrickStore
|
||||
|
||||
|
||||
def update_active_brick_index(self, context):
|
||||
@@ -69,3 +70,7 @@ class BIMBrickProperties(PropertyGroup):
|
||||
libraries: EnumProperty(name="Libraries", items=get_libraries)
|
||||
namespace: EnumProperty(name="Namespace", items=get_namespaces)
|
||||
brick_equipment_class: EnumProperty(name="Brick Equipment Class", items=get_brick_equipment_classes)
|
||||
brick_settings_toggled: BoolProperty(name="Brick Settings Toggled", default=False)
|
||||
new_brick_label: StringProperty(name="New Brick Label")
|
||||
new_brick_namespace_alias: StringProperty(name="New Brick Namespace Alias")
|
||||
new_brick_namespace_uri: StringProperty(name="New Brick Namespace URI")
|
||||
@@ -49,11 +49,31 @@ class BIM_PT_brickschema(Panel):
|
||||
if len(self.props.brick_breadcrumbs):
|
||||
row.operator("bim.rewind_brick_class", text="", icon="FRAME_PREV")
|
||||
row.label(text=self.props.active_brick_class)
|
||||
row.prop(data=self.props, property="brick_settings_toggled", text="", icon="PREFERENCES")
|
||||
row.operator("bim.refresh_brick_viewer", text="", icon="FILE_REFRESH")
|
||||
row.operator("bim.close_brick_project", text="", icon="CANCEL")
|
||||
|
||||
if self.props.brick_settings_toggled:
|
||||
box = self.layout.box()
|
||||
row = box.row(align=True)
|
||||
row.label(text="Active Namespace:")
|
||||
row = box.row(align=True)
|
||||
prop_with_search(row, self.props, "namespace", text="")
|
||||
row = box.row(align=True)
|
||||
row.label(text="Bind New Namespace:")
|
||||
row = box.row(align=True)
|
||||
row.prop(data=self.props, property="new_brick_namespace_alias", text="")
|
||||
col = row.column()
|
||||
col.alignment = "CENTER"
|
||||
col.scale_x = 1.1
|
||||
col.label(text=":")
|
||||
row.prop(data=self.props, property="new_brick_namespace_uri", text="")
|
||||
row.operator("bim.add_brick_namespace", text="", icon="ADD")
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
prop_with_search(row, self.props, "namespace", text="")
|
||||
row.label(text="Create Entity:")
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(data=self.props, property="new_brick_label", text="")
|
||||
prop_with_search(row, self.props, "brick_equipment_class", text="")
|
||||
row.operator("bim.add_brick", text="", icon="ADD")
|
||||
|
||||
|
||||
@@ -68,13 +68,13 @@ def assign_brick_reference(ifc, brick, element=None, library=None, brick_uri=Non
|
||||
brick.add_brickifc_reference(brick_uri, element, project)
|
||||
|
||||
|
||||
def add_brick(ifc, brick, element=None, namespace=None, brick_class=None, library=None):
|
||||
def add_brick(ifc, brick, element=None, namespace=None, brick_class=None, library=None, label="Unnamed"):
|
||||
if element:
|
||||
brick_uri = brick.add_brick_from_element(element, namespace, brick_class)
|
||||
if library:
|
||||
brick.run_assign_brick_reference(element=element, library=library, brick_uri=brick_uri)
|
||||
else:
|
||||
brick_uri = brick.add_brick(namespace, brick_class)
|
||||
brick_uri = brick.add_brick(namespace, brick_class, label)
|
||||
brick.run_refresh_brick_viewer()
|
||||
|
||||
|
||||
@@ -123,4 +123,7 @@ def redo_brick(brick):
|
||||
|
||||
|
||||
def serialize_brick(brick):
|
||||
brick.serialize_brick()
|
||||
brick.serialize_brick()
|
||||
|
||||
def add_namespace(brick, alias=None, uri=None):
|
||||
brick.add_namespace(alias, uri)
|
||||
|
||||
@@ -41,12 +41,12 @@ logger.setLevel(logging.ERROR)
|
||||
|
||||
class Brick(blenderbim.core.tool.Brick):
|
||||
@classmethod
|
||||
def add_brick(cls, namespace, brick_class):
|
||||
def add_brick(cls, namespace, brick_class, label):
|
||||
ns = Namespace(namespace)
|
||||
brick = ns[ifcopenshell.guid.expand(ifcopenshell.guid.new())]
|
||||
with BrickStore.graph.new_changeset("PROJECT") as cs:
|
||||
cs.add((brick, RDF.type, URIRef(brick_class)))
|
||||
cs.add((brick, URIRef("http://www.w3.org/2000/01/rdf-schema#label"), Literal("Unnamed")))
|
||||
cs.add((brick, URIRef("http://www.w3.org/2000/01/rdf-schema#label"), Literal(label)))
|
||||
return str(brick)
|
||||
|
||||
@classmethod
|
||||
@@ -333,8 +333,12 @@ class Brick(blenderbim.core.tool.Brick):
|
||||
|
||||
@classmethod
|
||||
def serialize_brick(cls):
|
||||
print(BrickStore.path)
|
||||
BrickStore.get_project().serialize(destination=BrickStore.path, format="turtle")
|
||||
|
||||
@classmethod
|
||||
def add_namespace(cls, alias, uri):
|
||||
BrickStore.graph.bind(alias, Namespace(uri))
|
||||
# need some way to reload namespace enum view
|
||||
|
||||
class BrickStore:
|
||||
schema = None # this is now a os path
|
||||
|
||||
Reference in New Issue
Block a user