mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-31 00:46:36 +00:00
#1153 You can now add / remove / open schedules, implemented as IFC documents
This commit is contained in:
@@ -126,6 +126,71 @@ class TestRemoveSheet:
|
||||
subject.remove_sheet(ifc, drawing, sheet="sheet")
|
||||
|
||||
|
||||
class TestLoadSchedules:
|
||||
def test_run(self, drawing):
|
||||
drawing.import_schedules().should_be_called()
|
||||
drawing.enable_editing_schedules().should_be_called()
|
||||
subject.load_schedules(drawing)
|
||||
|
||||
|
||||
class TestDisableEditingSchedules:
|
||||
def test_run(self, drawing):
|
||||
drawing.disable_editing_schedules().should_be_called()
|
||||
subject.disable_editing_schedules(drawing)
|
||||
|
||||
|
||||
class TestAddSchedule:
|
||||
def test_run(self, ifc, drawing):
|
||||
ifc.run("document.add_information").should_be_called().will_return("schedule")
|
||||
ifc.run("document.add_reference", information="schedule").should_be_called().will_return("reference")
|
||||
ifc.get_schema().should_be_called().will_return("IFC4")
|
||||
ifc.run(
|
||||
"document.edit_information",
|
||||
information="schedule",
|
||||
attributes={"Identification": "X", "Name": "UNTITLED", "Scope": "SCHEDULE", "Location": "uri"},
|
||||
).should_be_called()
|
||||
drawing.import_schedules().should_be_called()
|
||||
subject.add_schedule(ifc, drawing, uri="uri")
|
||||
|
||||
def test_using_a_document_id_in_ifc2x3(self, ifc, drawing):
|
||||
ifc.run("document.add_information").should_be_called().will_return("schedule")
|
||||
ifc.run("document.add_reference", information="schedule").should_be_called().will_return("reference")
|
||||
ifc.get_schema().should_be_called().will_return("IFC2X3")
|
||||
ifc.run(
|
||||
"document.edit_information",
|
||||
information="schedule",
|
||||
attributes={"DocumentId": "X", "Name": "UNTITLED", "Scope": "SCHEDULE"},
|
||||
).should_be_called()
|
||||
ifc.run("document.edit_reference", reference="reference", attributes={"Location": "uri"}).should_be_called()
|
||||
drawing.import_schedules().should_be_called()
|
||||
subject.add_schedule(ifc, drawing, uri="uri")
|
||||
|
||||
|
||||
class TestRemoveSchedule:
|
||||
def test_run(self, ifc, drawing):
|
||||
ifc.run("document.remove_information", information="schedule").should_be_called()
|
||||
drawing.import_schedules().should_be_called()
|
||||
subject.remove_schedule(ifc, drawing, schedule="schedule")
|
||||
|
||||
|
||||
class TestOpenSchedule:
|
||||
def test_run(self, drawing):
|
||||
drawing.get_schedule_location("schedule").should_be_called().will_return("uri")
|
||||
drawing.open_spreadsheet("uri").should_be_called()
|
||||
subject.open_schedule(drawing, schedule="schedule")
|
||||
|
||||
|
||||
class TestUpdateScheduleName:
|
||||
def test_do_not_update_if_name_unchanged(self, ifc, drawing):
|
||||
drawing.get_name("schedule").should_be_called().will_return("name")
|
||||
subject.update_drawing_name(ifc, drawing, schedule="schedule", name="name")
|
||||
|
||||
def test_run(self, ifc, drawing):
|
||||
drawing.get_name("schedule").should_be_called().will_return("oldname")
|
||||
ifc.run("document.edit_information", information="schedule", attributes={"Name": "name"}).should_be_called()
|
||||
subject.update_drawing_name(ifc, drawing, schedule="schedule", name="name")
|
||||
|
||||
|
||||
class TestLoadDrawings:
|
||||
def test_run(self, drawing):
|
||||
drawing.import_drawings().should_be_called()
|
||||
|
||||
@@ -60,8 +60,8 @@ class TestAddRepresentation:
|
||||
profile_set_usage="profile_set_usage",
|
||||
).should_be_called().will_return("representation")
|
||||
|
||||
# Styles are relevant for meshes with faces only
|
||||
geometry.does_object_have_mesh_with_faces("obj").should_be_called().will_return(True)
|
||||
# Styles are relevant for body representations only (as a simplification)
|
||||
geometry.is_body_representation("representation").should_be_called().will_return(True)
|
||||
|
||||
# Add styles
|
||||
geometry.get_object_materials_without_styles("obj").should_be_called().will_return(["material"])
|
||||
@@ -102,7 +102,7 @@ class TestAddRepresentation:
|
||||
== "representation"
|
||||
)
|
||||
|
||||
def test_not_handling_styles_if_representation_has_no_faces(self, ifc, geometry, style, surveyor):
|
||||
def test_not_handling_styles_if_not_a_body_representation(self, ifc, geometry, style, surveyor):
|
||||
TestEditObjectPlacement.predict(self, ifc, geometry, surveyor)
|
||||
|
||||
# Add representation
|
||||
@@ -126,8 +126,8 @@ class TestAddRepresentation:
|
||||
profile_set_usage="profile_set_usage",
|
||||
).should_be_called().will_return("representation")
|
||||
|
||||
# Styles are relevant for meshes with faces only
|
||||
geometry.does_object_have_mesh_with_faces("obj").should_be_called().will_return(False)
|
||||
# Styles are relevant for body representations only (as a simplification)
|
||||
geometry.is_body_representation("representation").should_be_called().will_return(False)
|
||||
|
||||
# Assign representation to product
|
||||
ifc.run("geometry.assign_representation", product="element", representation="representation").should_be_called()
|
||||
|
||||
@@ -87,6 +87,13 @@ class TestDisableEditingDrawings(NewFile):
|
||||
assert bpy.context.scene.DocProperties.is_editing_drawings == False
|
||||
|
||||
|
||||
class TestDisableEditingSchedules(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_schedules = True
|
||||
subject.disable_editing_schedules()
|
||||
assert bpy.context.scene.DocProperties.is_editing_schedules == False
|
||||
|
||||
|
||||
class TestDisableEditingSheets(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_sheets = True
|
||||
@@ -125,6 +132,13 @@ class TestEnableEditingDrawings(NewFile):
|
||||
assert bpy.context.scene.DocProperties.is_editing_drawings == True
|
||||
|
||||
|
||||
class TestEnableEditingSchedules(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_schedules = False
|
||||
subject.enable_editing_schedules()
|
||||
assert bpy.context.scene.DocProperties.is_editing_schedules == True
|
||||
|
||||
|
||||
class TestEnableEditingSheets(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_sheets = False
|
||||
@@ -263,6 +277,22 @@ class TestGetName(NewFile):
|
||||
assert subject.get_name(ifc.createIfcWall(Name="Foobar")) == "Foobar"
|
||||
|
||||
|
||||
class TestGetScheduleLocation(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
|
||||
schedule = ifcopenshell.api.run("document.add_information", ifc)
|
||||
schedule.Location = "uri"
|
||||
reference = ifcopenshell.api.run("document.add_reference", ifc, information=schedule)
|
||||
subject.get_schedule_location(schedule) == "uri"
|
||||
|
||||
def test_run_ifc2x3(self):
|
||||
ifc = ifcopenshell.file(schema="IFC2X3")
|
||||
reference = ifc.createIfcDocumentReference(Location="uri")
|
||||
schedule = ifc.createIfcDocumentInformation(DocumentReferences=[reference])
|
||||
subject.get_sheet_filename(schedule) == "uri"
|
||||
|
||||
|
||||
class TestGetSheetFilename(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
@@ -408,6 +438,30 @@ class TestImportDrawings(NewFile):
|
||||
assert props.drawings[0].target_view == "PLAN_VIEW"
|
||||
|
||||
|
||||
class TestImportSchedules(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
ifc.createIfcDocumentInformation(Identification="Y", Name="FOOBAZ")
|
||||
document = ifc.createIfcDocumentInformation(Identification="X", Name="FOOBAR", Scope="SCHEDULE")
|
||||
subject.import_schedules()
|
||||
props = bpy.context.scene.DocProperties
|
||||
assert props.schedules[0].ifc_definition_id == document.id()
|
||||
assert props.schedules[0].identification == "X"
|
||||
assert props.schedules[0].name == "FOOBAR"
|
||||
|
||||
def test_run_ifc2x3(self):
|
||||
ifc = ifcopenshell.file(schema="IFC2X3")
|
||||
tool.Ifc.set(ifc)
|
||||
ifc.createIfcDocumentInformation(DocumentId="Y", Name="FOOBAZ")
|
||||
document = ifc.createIfcDocumentInformation(DocumentId="X", Name="FOOBAR", Scope="SCHEDULE")
|
||||
subject.import_schedules()
|
||||
props = bpy.context.scene.DocProperties
|
||||
assert props.schedules[0].ifc_definition_id == document.id()
|
||||
assert props.schedules[0].identification == "X"
|
||||
assert props.schedules[0].name == "FOOBAR"
|
||||
|
||||
|
||||
class TestImportSheets(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
@@ -475,6 +529,11 @@ class TestImportTextProduct(NewFile):
|
||||
assert label_obj.BIMTextProperties.relating_product is None
|
||||
|
||||
|
||||
class TestOpenSchedule(NewFile):
|
||||
def open_spreadsheet(self):
|
||||
pass
|
||||
|
||||
|
||||
class TestOpenSvg(NewFile):
|
||||
def test_nothing(self):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user