mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
#1153. Drawing names are now generated based on their location and show an icon based on the drawing type.
This commit is contained in:
@@ -1070,8 +1070,10 @@ class CopyGrid(bpy.types.Operator):
|
|||||||
return helper.get_active_drawing(context.scene)[0] is not None
|
return helper.get_active_drawing(context.scene)[0] is not None
|
||||||
|
|
||||||
def execute(self, context):
|
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(
|
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:
|
if not subcontext:
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -1080,8 +1082,8 @@ class CopyGrid(bpy.types.Operator):
|
|||||||
view_coll, camera = helper.get_active_drawing(context.scene)
|
view_coll, camera = helper.get_active_drawing(context.scene)
|
||||||
is_ortho = camera.data.type == "ORTHO"
|
is_ortho = camera.data.type == "ORTHO"
|
||||||
bounds = helper.ortho_view_frame(camera.data) if is_ortho else None
|
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")
|
clipping = is_ortho and target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW")
|
||||||
elevating = is_ortho and camera.data.BIMCameraProperties.target_view in ("ELEVATION_VIEW", "SECTION_VIEW")
|
elevating = is_ortho and target_view in ("ELEVATION_VIEW", "SECTION_VIEW")
|
||||||
|
|
||||||
def grep(coll):
|
def grep(coll):
|
||||||
results = []
|
results = []
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ class Variable(PropertyGroup):
|
|||||||
class Drawing(PropertyGroup):
|
class Drawing(PropertyGroup):
|
||||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||||
name: StringProperty(name="Name", update=update_drawing_name)
|
name: StringProperty(name="Name", update=update_drawing_name)
|
||||||
|
target_view: StringProperty(name="Target View")
|
||||||
|
|
||||||
|
|
||||||
class Schedule(PropertyGroup):
|
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):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
if item:
|
if item:
|
||||||
row = layout.row(align=True)
|
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:
|
else:
|
||||||
layout.label(text="", translate=False)
|
layout.label(text="", translate=False)
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ def disable_editing_drawings(drawing):
|
|||||||
|
|
||||||
|
|
||||||
def add_drawing(ifc, collector, drawing, target_view=None, location_hint=None):
|
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)
|
drawing_matrix = drawing.generate_drawing_matrix(target_view, location_hint)
|
||||||
camera = drawing.create_camera(drawing_name, drawing_matrix)
|
camera = drawing.create_camera(drawing_name, drawing_matrix)
|
||||||
element = drawing.run_root_assign_class(
|
element = drawing.run_root_assign_class(
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ class Drawing:
|
|||||||
def ensure_unique_identification(cls, identification): pass
|
def ensure_unique_identification(cls, identification): pass
|
||||||
def export_text_literal_attributes(cls, obj): pass
|
def export_text_literal_attributes(cls, obj): pass
|
||||||
def generate_drawing_matrix(cls, target_view, location_hint): 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 generate_sheet_identification(cls): pass
|
||||||
def get_annotation_context(cls, target_view): pass
|
def get_annotation_context(cls, target_view): pass
|
||||||
def get_body_context(cls): pass
|
def get_body_context(cls): pass
|
||||||
|
|||||||
@@ -260,6 +260,7 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
new = bpy.context.scene.DocProperties.drawings.add()
|
new = bpy.context.scene.DocProperties.drawings.add()
|
||||||
new.ifc_definition_id = drawing.id()
|
new.ifc_definition_id = drawing.id()
|
||||||
new.name = drawing.Name or "Unnamed"
|
new.name = drawing.Name or "Unnamed"
|
||||||
|
new.target_view = cls.get_drawing_target_view(drawing)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def import_sheets(cls):
|
def import_sheets(cls):
|
||||||
@@ -349,3 +350,16 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
for variable in re.findall("{{.*?}}", value):
|
for variable in re.findall("{{.*?}}", value):
|
||||||
value = value.replace(variable, selector.get_element_value(product, variable[2:-2]) or "")
|
value = value.replace(variable, selector.get_element_value(product, variable[2:-2]) or "")
|
||||||
obj.BIMTextProperties.value = value
|
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
|
||||||
|
|||||||
@@ -399,10 +399,13 @@ class TestImportDrawings(NewFile):
|
|||||||
ifc = ifcopenshell.file()
|
ifc = ifcopenshell.file()
|
||||||
tool.Ifc.set(ifc)
|
tool.Ifc.set(ifc)
|
||||||
drawing = ifc.createIfcAnnotation(Name="FOOBAR", ObjectType="DRAWING")
|
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()
|
subject.import_drawings()
|
||||||
props = bpy.context.scene.DocProperties
|
props = bpy.context.scene.DocProperties
|
||||||
assert props.drawings[0].ifc_definition_id == drawing.id()
|
assert props.drawings[0].ifc_definition_id == drawing.id()
|
||||||
assert props.drawings[0].name == "FOOBAR"
|
assert props.drawings[0].name == "FOOBAR"
|
||||||
|
assert props.drawings[0].target_view == "PLAN_VIEW"
|
||||||
|
|
||||||
|
|
||||||
class TestImportSheets(NewFile):
|
class TestImportSheets(NewFile):
|
||||||
|
|||||||
Reference in New Issue
Block a user