#1153. Drawing names are now generated based on their location and show an icon based on the drawing type.

This commit is contained in:
Dion Moult
2022-03-18 15:49:56 +11:00
parent 074a55b816
commit 2bfff12988
7 changed files with 35 additions and 5 deletions
@@ -1070,8 +1070,10 @@ class CopyGrid(bpy.types.Operator):
return helper.get_active_drawing(context.scene)[0] is not None
def execute(self, context):
drawing = tool.Ifc.get_entity(context.scene.camera)
target_view = tool.Drawing.get_drawing_target_view(drawing)
subcontext = ifcopenshell.util.representation.get_context(
IfcStore.get_file(), "Plan", "Annotation", context.scene.camera.data.BIMCameraProperties.target_view
IfcStore.get_file(), "Plan", "Annotation", target_view
)
if not subcontext:
return {"FINISHED"}
@@ -1080,8 +1082,8 @@ class CopyGrid(bpy.types.Operator):
view_coll, camera = helper.get_active_drawing(context.scene)
is_ortho = camera.data.type == "ORTHO"
bounds = helper.ortho_view_frame(camera.data) if is_ortho else None
clipping = is_ortho and camera.data.BIMCameraProperties.target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW")
elevating = is_ortho and camera.data.BIMCameraProperties.target_view in ("ELEVATION_VIEW", "SECTION_VIEW")
clipping = is_ortho and target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW")
elevating = is_ortho and target_view in ("ELEVATION_VIEW", "SECTION_VIEW")
def grep(coll):
results = []
@@ -199,6 +199,7 @@ class Variable(PropertyGroup):
class Drawing(PropertyGroup):
ifc_definition_id: IntProperty(name="IFC Definition ID")
name: StringProperty(name="Name", update=update_drawing_name)
target_view: StringProperty(name="Target View")
class Schedule(PropertyGroup):
@@ -369,7 +369,16 @@ class BIM_UL_drawinglist(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
if item:
row = layout.row(align=True)
row.prop(item, "name", text="", emboss=False)
icon = "UV_FACESEL"
if item.target_view == "ELEVATION_VIEW":
icon = "UV_VERTEXSEL"
elif item.target_view == "SECTION_VIEW":
icon = "UV_EDGESEL"
elif item.target_view == "REFLECTED_PLAN_VIEW":
icon = "XRAY"
elif item.target_view == "MODEL_VIEW":
icon = "SNAP_VOLUME"
row.prop(item, "name", text="", icon=icon, emboss=False)
else:
layout.label(text="", translate=False)
+1 -1
View File
@@ -99,7 +99,7 @@ def disable_editing_drawings(drawing):
def add_drawing(ifc, collector, drawing, target_view=None, location_hint=None):
drawing_name = drawing.ensure_unique_drawing_name("UNTITLED")
drawing_name = drawing.ensure_unique_drawing_name(drawing.generate_drawing_name(target_view, location_hint))
drawing_matrix = drawing.generate_drawing_matrix(target_view, location_hint)
camera = drawing.create_camera(drawing_name, drawing_matrix)
element = drawing.run_root_assign_class(
+1
View File
@@ -172,6 +172,7 @@ class Drawing:
def ensure_unique_identification(cls, identification): pass
def export_text_literal_attributes(cls, obj): pass
def generate_drawing_matrix(cls, target_view, location_hint): pass
def generate_drawing_name(cls, target_view, location_hint): pass
def generate_sheet_identification(cls): pass
def get_annotation_context(cls, target_view): pass
def get_body_context(cls): pass
+14
View File
@@ -260,6 +260,7 @@ class Drawing(blenderbim.core.tool.Drawing):
new = bpy.context.scene.DocProperties.drawings.add()
new.ifc_definition_id = drawing.id()
new.name = drawing.Name or "Unnamed"
new.target_view = cls.get_drawing_target_view(drawing)
@classmethod
def import_sheets(cls):
@@ -349,3 +350,16 @@ class Drawing(blenderbim.core.tool.Drawing):
for variable in re.findall("{{.*?}}", value):
value = value.replace(variable, selector.get_element_value(product, variable[2:-2]) or "")
obj.BIMTextProperties.value = value
# TODO below this point is highly experimental prototype code with no tests
@classmethod
def generate_drawing_name(cls, target_view, location_hint):
if target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW") and location_hint:
location = tool.Ifc.get().by_id(location_hint)
if target_view == "REFLECTED_PLAN_VIEW":
target_view = "RCP_VIEW"
return (location.Name or "UNNAMED").upper() + " " + target_view.split("_")[0]
elif target_view in ("SECTION_VIEW", "ELEVATION_VIEW") and location_hint:
return location_hint + " " + target_view.split("_")[0]
return target_view
+3
View File
@@ -399,10 +399,13 @@ class TestImportDrawings(NewFile):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
drawing = ifc.createIfcAnnotation(Name="FOOBAR", ObjectType="DRAWING")
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=drawing, name="EPset_Drawing")
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"TargetView": "PLAN_VIEW"})
subject.import_drawings()
props = bpy.context.scene.DocProperties
assert props.drawings[0].ifc_definition_id == drawing.id()
assert props.drawings[0].name == "FOOBAR"
assert props.drawings[0].target_view == "PLAN_VIEW"
class TestImportSheets(NewFile):