mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Remove create project library ability, as you should create a project first
This commit is contained in:
@@ -22,7 +22,6 @@ from . import ui, prop, operator
|
|||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
operator.CreateProject,
|
operator.CreateProject,
|
||||||
operator.CreateProjectLibrary,
|
|
||||||
operator.SelectLibraryFile,
|
operator.SelectLibraryFile,
|
||||||
operator.ChangeLibraryElement,
|
operator.ChangeLibraryElement,
|
||||||
operator.RefreshLibrary,
|
operator.RefreshLibrary,
|
||||||
|
|||||||
@@ -96,46 +96,6 @@ class CreateProject(bpy.types.Operator):
|
|||||||
IfcStore.file = data["file"]
|
IfcStore.file = data["file"]
|
||||||
|
|
||||||
|
|
||||||
class CreateProjectLibrary(bpy.types.Operator):
|
|
||||||
bl_idname = "bim.create_project_library"
|
|
||||||
bl_label = "Create Project Library"
|
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
|
||||||
|
|
||||||
def execute(self, context):
|
|
||||||
IfcStore.begin_transaction(self)
|
|
||||||
IfcStore.add_transaction_operation(self, rollback=self.rollback, commit=lambda data: True)
|
|
||||||
result = self._execute(context)
|
|
||||||
self.transaction_data = {"file": self.file}
|
|
||||||
IfcStore.add_transaction_operation(self, rollback=lambda data: True, commit=self.commit)
|
|
||||||
IfcStore.end_transaction(self)
|
|
||||||
return result
|
|
||||||
|
|
||||||
def _execute(self, context):
|
|
||||||
self.file = IfcStore.get_file()
|
|
||||||
if self.file:
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
IfcStore.file = ifcopenshell.api.run(
|
|
||||||
"project.create_file", **{"version": context.scene.BIMProperties.export_schema}
|
|
||||||
)
|
|
||||||
self.file = IfcStore.get_file()
|
|
||||||
|
|
||||||
if self.file.schema == "IFC2X3":
|
|
||||||
bpy.ops.bim.add_person()
|
|
||||||
bpy.ops.bim.add_organisation()
|
|
||||||
|
|
||||||
project_library = bpy.data.objects.new("My Project Library", None)
|
|
||||||
bpy.ops.bim.assign_class(obj=project_library.name, ifc_class="IfcProjectLibrary")
|
|
||||||
bpy.ops.bim.assign_unit()
|
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
def rollback(self, data):
|
|
||||||
IfcStore.file = None
|
|
||||||
|
|
||||||
def commit(self, data):
|
|
||||||
IfcStore.file = data["file"]
|
|
||||||
|
|
||||||
|
|
||||||
class SelectLibraryFile(bpy.types.Operator):
|
class SelectLibraryFile(bpy.types.Operator):
|
||||||
bl_idname = "bim.select_library_file"
|
bl_idname = "bim.select_library_file"
|
||||||
bl_label = "Select Library File"
|
bl_label = "Select Library File"
|
||||||
|
|||||||
@@ -112,9 +112,6 @@ class BIM_PT_project(Panel):
|
|||||||
row.prop(props, "volume_unit", text="Volume Unit")
|
row.prop(props, "volume_unit", text="Volume Unit")
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.operator("bim.create_project")
|
row.operator("bim.create_project")
|
||||||
if props.export_schema != "IFC2X3":
|
|
||||||
row = self.layout.row()
|
|
||||||
row.operator("bim.create_project_library")
|
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_project_library(Panel):
|
class BIM_PT_project_library(Panel):
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ class NewFile:
|
|||||||
def scenario(function):
|
def scenario(function):
|
||||||
def subfunction(self):
|
def subfunction(self):
|
||||||
run(function(self))
|
run(function(self))
|
||||||
|
|
||||||
return subfunction
|
return subfunction
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +44,7 @@ def i_add_a_cube():
|
|||||||
bpy.ops.mesh.primitive_cube_add()
|
bpy.ops.mesh.primitive_cube_add()
|
||||||
|
|
||||||
|
|
||||||
def the_object_named_name_is_selected(name):
|
def the_object_name_is_selected(name):
|
||||||
obj = bpy.context.scene.objects.get(name)
|
obj = bpy.context.scene.objects.get(name)
|
||||||
if not obj:
|
if not obj:
|
||||||
assert False, 'The object "{name}" could not be selected'
|
assert False, 'The object "{name}" could not be selected'
|
||||||
@@ -62,7 +61,7 @@ def i_press_operator(operator):
|
|||||||
exec(f"bpy.ops.{operator}()")
|
exec(f"bpy.ops.{operator}()")
|
||||||
|
|
||||||
|
|
||||||
def the_object_named_name_exists(name):
|
def the_object_name_exists(name):
|
||||||
obj = bpy.data.objects.get(name)
|
obj = bpy.data.objects.get(name)
|
||||||
if not obj:
|
if not obj:
|
||||||
assert False, f'The object "{name}" does not exist'
|
assert False, f'The object "{name}" does not exist'
|
||||||
@@ -76,19 +75,24 @@ def an_ifc_file_exists():
|
|||||||
return ifc
|
return ifc
|
||||||
|
|
||||||
|
|
||||||
def the_object_named_name_is_an_ifc_class(name, ifc_class):
|
def the_object_name_is_an_ifc_class(name, ifc_class):
|
||||||
ifc = an_ifc_file_exists()
|
ifc = an_ifc_file_exists()
|
||||||
element = ifc.by_id(the_object_named_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
element = ifc.by_id(the_object_name_exists(name).BIMObjectProperties.ifc_definition_id)
|
||||||
assert element.is_a(ifc_class), f'Object "{name}" is a {element.is_a()}'
|
assert element.is_a(ifc_class), f'Object "{name}" is a {element.is_a()}'
|
||||||
|
|
||||||
|
|
||||||
|
def the_object_name_is_in_the_collection_collection(name, collection):
|
||||||
|
assert collection in [c.name for c in the_object_name_exists(name).users_collection]
|
||||||
|
|
||||||
|
|
||||||
definitions = {
|
definitions = {
|
||||||
"an empty IFC project": an_empty_ifc_project,
|
"an empty IFC project": an_empty_ifc_project,
|
||||||
"I add a cube": i_add_a_cube,
|
"I add a cube": i_add_a_cube,
|
||||||
'the object named "(.*)" is selected': the_object_named_name_is_selected,
|
'the object "(.*)" is selected': the_object_name_is_selected,
|
||||||
'I select "(.*)" in "(.*)"': i_select_value_in_prop,
|
'I select "(.*)" in "(.*)"': i_select_value_in_prop,
|
||||||
'I press "(.*)"': i_press_operator,
|
'I press "(.*)"': i_press_operator,
|
||||||
'the object named "(.*)" is an "(.*)"': the_object_named_name_is_an_ifc_class,
|
'the object "(.*)" is an "(.*)"': the_object_name_is_an_ifc_class,
|
||||||
|
'the object "(.*)" is in the collection "(.*)"': the_object_name_is_in_the_collection_collection,
|
||||||
"an IFC file exists": an_ifc_file_exists,
|
"an IFC file exists": an_ifc_file_exists,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,12 @@ class TestCreateProject(test.bim.bootstrap.NewFile):
|
|||||||
return """
|
return """
|
||||||
When I press "bim.create_project"
|
When I press "bim.create_project"
|
||||||
Then an IFC file exists
|
Then an IFC file exists
|
||||||
And the object named "IfcProject/My Project" is an "IfcProject"
|
And the object "IfcProject/My Project" is an "IfcProject"
|
||||||
And the object named "IfcSite/My Site" is an "IfcSite"
|
And the object "IfcSite/My Site" is an "IfcSite"
|
||||||
And the object named "IfcBuilding/My Building" is an "IfcBuilding"
|
And the object "IfcBuilding/My Building" is an "IfcBuilding"
|
||||||
And the object named "IfcBuildingStorey/My Storey" is an "IfcBuildingStorey"
|
And the object "IfcBuildingStorey/My Storey" is an "IfcBuildingStorey"
|
||||||
|
And the object "IfcProject/My Project" is in the collection "IfcProject/My Project"
|
||||||
|
And the object "IfcSite/My Site" is in the collection "IfcSite/My Site"
|
||||||
|
And the object "IfcBuilding/My Building" is in the collection "IfcBuilding/My Building"
|
||||||
|
And the object "IfcBuildingStorey/My Storey" is in the collection "IfcBuildingStorey/My Storey"
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -19,14 +19,27 @@
|
|||||||
import test.bim.bootstrap
|
import test.bim.bootstrap
|
||||||
|
|
||||||
|
|
||||||
class TestCreateProject(test.bim.bootstrap.NewFile):
|
class TestAssignClass(test.bim.bootstrap.NewFile):
|
||||||
@test.bim.bootstrap.scenario
|
@test.bim.bootstrap.scenario
|
||||||
def test_assigning_a_class_to_a_cube(self):
|
def test_assigning_a_class_to_a_cube(self):
|
||||||
return """
|
return """
|
||||||
Given an empty IFC project
|
Given an empty IFC project
|
||||||
When I add a cube
|
When I add a cube
|
||||||
And the object named "Cube" is selected
|
And the object "Cube" is selected
|
||||||
And I select "IfcWall" in "scene.BIMRootProperties.ifc_class"
|
And I select "IfcWall" in "scene.BIMRootProperties.ifc_class"
|
||||||
And I press "bim.assign_class"
|
And I press "bim.assign_class"
|
||||||
And the object named "IfcWall/Cube" is an "IfcWall"
|
And the object "IfcWall/Cube" is an "IfcWall"
|
||||||
|
"""
|
||||||
|
|
||||||
|
@test.bim.bootstrap.scenario
|
||||||
|
def test_assigning_a_type_class_to_a_cube(self):
|
||||||
|
return """
|
||||||
|
Given an empty IFC project
|
||||||
|
When I add a cube
|
||||||
|
And the object "Cube" is selected
|
||||||
|
And I select "IfcElementType" in "scene.BIMRootProperties.ifc_product"
|
||||||
|
And I select "IfcWallType" in "scene.BIMRootProperties.ifc_class"
|
||||||
|
And I press "bim.assign_class"
|
||||||
|
And the object "IfcWallType/Cube" is an "IfcWallType"
|
||||||
|
And the object "IfcWallType/Cube" is in the collection "Types"
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user