mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
#1153 Drawings that are pure annotation now do not generate references
This commit is contained in:
@@ -149,9 +149,6 @@ class SvgWriter:
|
||||
self.draw_dimension_annotations(obj)
|
||||
self.draw_measureit_arch_dimension_annotations()
|
||||
|
||||
if self.annotations.get("break_obj"):
|
||||
self.draw_break_annotations(self.annotations["break_obj"])
|
||||
|
||||
for grid_obj in self.annotations.get("grid_objs", []):
|
||||
matrix_world = grid_obj.matrix_world
|
||||
classes = self.get_attribute_classes(grid_obj)
|
||||
@@ -293,6 +290,9 @@ class SvgWriter:
|
||||
for text_obj in self.annotations.get("text_objs", []):
|
||||
self.draw_text_annotation(text_obj, text_obj.location)
|
||||
|
||||
if self.annotations.get("break_obj"):
|
||||
self.draw_break_annotations(self.annotations["break_obj"])
|
||||
|
||||
def draw_ifc_annotation(self):
|
||||
x_offset = self.raw_width / 2
|
||||
y_offset = self.raw_height / 2
|
||||
|
||||
@@ -115,7 +115,18 @@ def add_drawing(ifc, collector, drawing, target_view=None, location_hint=None):
|
||||
ifc.run("group.assign_group", group=group, product=element)
|
||||
collector.assign(camera)
|
||||
pset = ifc.run("pset.add_pset", product=element, name="EPset_Drawing")
|
||||
ifc.run("pset.edit_pset", pset=pset, properties={"TargetView": target_view, "Scale": "1/100", "HumanScale": "1:100"})
|
||||
ifc.run(
|
||||
"pset.edit_pset",
|
||||
pset=pset,
|
||||
properties={
|
||||
"TargetView": target_view,
|
||||
"Scale": "1/100",
|
||||
"HumanScale": "1:100",
|
||||
"HasUnderlay": False,
|
||||
"HasLinework": True,
|
||||
"HasAnnotation": True,
|
||||
},
|
||||
)
|
||||
drawing.import_drawings()
|
||||
|
||||
|
||||
@@ -161,6 +172,9 @@ def add_annotation(ifc, collector, drawing_tool, drawing=None, object_type=None)
|
||||
|
||||
|
||||
def sync_references(ifc, collector, drawing_tool, drawing=None):
|
||||
if not drawing_tool.has_linework(drawing):
|
||||
return
|
||||
|
||||
context = drawing_tool.get_annotation_context(drawing_tool.get_drawing_target_view(drawing))
|
||||
if not context:
|
||||
return
|
||||
|
||||
@@ -21,6 +21,7 @@ def copy_class(ifc, collector, geometry, root, obj=None):
|
||||
element = ifc.get_entity(obj)
|
||||
if not element:
|
||||
return
|
||||
representation = root.get_object_representation(obj)
|
||||
element = ifc.run("root.copy_class", product=element)
|
||||
ifc.link(element, obj)
|
||||
relating_type = root.get_element_type(element)
|
||||
@@ -28,7 +29,6 @@ def copy_class(ifc, collector, geometry, root, obj=None):
|
||||
ifc.run("type.map_type_representations", related_object=element, relating_type=relating_type)
|
||||
root.link_object_data(ifc.get_object(relating_type), obj)
|
||||
else:
|
||||
representation = root.get_object_representation(obj)
|
||||
if representation:
|
||||
root.run_geometry_add_representation(
|
||||
obj=obj,
|
||||
|
||||
@@ -176,7 +176,7 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
|
||||
@classmethod
|
||||
def get_drawing_target_view(cls, drawing):
|
||||
return ifcopenshell.util.element.get_psets(drawing)["EPset_Drawing"]["TargetView"]
|
||||
return ifcopenshell.util.element.get_psets(drawing)["EPset_Drawing"].get("TargetView", "MODEL_VIEW")
|
||||
|
||||
@classmethod
|
||||
def get_group_elements(cls, group):
|
||||
@@ -730,7 +730,11 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
|
||||
@classmethod
|
||||
def get_drawing_human_scale(cls, drawing):
|
||||
return ifcopenshell.util.element.get_psets(drawing)["EPset_Drawing"]["HumanScale"]
|
||||
return ifcopenshell.util.element.get_psets(drawing)["EPset_Drawing"].get("HumanScale", "NTS")
|
||||
|
||||
@classmethod
|
||||
def has_linework(cls, drawing):
|
||||
return ifcopenshell.util.element.get_psets(drawing)["EPset_Drawing"].get("HasLinework", False)
|
||||
|
||||
@classmethod
|
||||
def get_annotation_element(cls, element):
|
||||
|
||||
@@ -58,6 +58,9 @@ class Root(blenderbim.core.tool.Root):
|
||||
def get_object_representation(cls, obj):
|
||||
if obj.data and obj.data.BIMMeshProperties.ifc_definition_id:
|
||||
return tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if not obj.data and getattr(element, "ObjectType", None) == "TEXT":
|
||||
return element.Representation.Representations[0]
|
||||
|
||||
@classmethod
|
||||
def get_representation_context(cls, representation):
|
||||
|
||||
@@ -121,7 +121,7 @@ class TestOpenSheet:
|
||||
|
||||
class TestRemoveSheet:
|
||||
def test_run(self, ifc, drawing):
|
||||
ifc.run("document.remove_document", document="sheet").should_be_called()
|
||||
ifc.run("document.remove_information", information="sheet").should_be_called()
|
||||
drawing.import_sheets().should_be_called()
|
||||
subject.remove_sheet(ifc, drawing, sheet="sheet")
|
||||
|
||||
@@ -162,7 +162,16 @@ class TestAddDrawing:
|
||||
collector.assign("obj").should_be_called()
|
||||
ifc.run("pset.add_pset", product="element", name="EPset_Drawing").should_be_called().will_return("pset")
|
||||
ifc.run(
|
||||
"pset.edit_pset", pset="pset", properties={"TargetView": "target_view", "Scale": "1/100"}
|
||||
"pset.edit_pset",
|
||||
pset="pset",
|
||||
properties={
|
||||
"TargetView": "target_view",
|
||||
"Scale": "1/100",
|
||||
"HumanScale": "1:100",
|
||||
"HasUnderlay": False,
|
||||
"HasLinework": True,
|
||||
"HasAnnotation": True,
|
||||
},
|
||||
).should_be_called()
|
||||
drawing.import_drawings().should_be_called()
|
||||
subject.add_drawing(ifc, collector, drawing, target_view="target_view", location_hint="location_hint")
|
||||
|
||||
@@ -28,6 +28,7 @@ class TestCopyClass:
|
||||
|
||||
def test_copy_with_new_geometry_derived_from_the_type(self, ifc, collector, root):
|
||||
ifc.get_entity("obj").should_be_called().will_return("original_element")
|
||||
root.get_object_representation("obj").should_be_called().will_return("representation")
|
||||
ifc.run("root.copy_class", product="original_element").should_be_called().will_return("element")
|
||||
ifc.link("element", "obj").should_be_called()
|
||||
root.get_element_type("element").should_be_called().will_return("type")
|
||||
@@ -41,12 +42,12 @@ class TestCopyClass:
|
||||
|
||||
def test_copy_with_new_geometry_added_afresh_for_speed(self, ifc, collector, geometry, root):
|
||||
ifc.get_entity("obj").should_be_called().will_return("original_element")
|
||||
root.get_object_representation("obj").should_be_called().will_return("representation")
|
||||
ifc.run("root.copy_class", product="original_element").should_be_called().will_return("element")
|
||||
ifc.link("element", "obj").should_be_called()
|
||||
root.get_element_type("element").should_be_called().will_return("type")
|
||||
root.does_type_have_representations("type").should_be_called().will_return(False)
|
||||
|
||||
root.get_object_representation("obj").should_be_called().will_return("representation")
|
||||
root.get_representation_context("representation").should_be_called().will_return("context")
|
||||
geometry.get_ifc_representation_class("element", "representation").should_be_called().will_return(
|
||||
"ifc_representation_class"
|
||||
@@ -64,17 +65,18 @@ class TestCopyClass:
|
||||
|
||||
def test_copy_with_no_new_geometry(self, ifc, collector, geometry, root):
|
||||
ifc.get_entity("obj").should_be_called().will_return("original_element")
|
||||
root.get_object_representation("obj").should_be_called().will_return(None)
|
||||
ifc.run("root.copy_class", product="original_element").should_be_called().will_return("element")
|
||||
ifc.link("element", "obj").should_be_called()
|
||||
root.get_element_type("element").should_be_called().will_return("type")
|
||||
root.does_type_have_representations("type").should_be_called().will_return(False)
|
||||
root.get_object_representation("obj").should_be_called().will_return(None)
|
||||
collector.assign("obj").should_be_called()
|
||||
root.is_opening_element("element").should_be_called().will_return(False)
|
||||
subject.copy_class(ifc, collector, geometry, root, obj="obj")
|
||||
|
||||
def test_copied_openings_have_dynamic_voids_added(self, ifc, collector, root):
|
||||
ifc.get_entity("obj").should_be_called().will_return("original_element")
|
||||
root.get_object_representation("obj").should_be_called().will_return(None)
|
||||
ifc.run("root.copy_class", product="original_element").should_be_called().will_return("element")
|
||||
ifc.link("element", "obj").should_be_called()
|
||||
root.get_element_type("element").should_be_called().will_return("type")
|
||||
|
||||
Reference in New Issue
Block a user