mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 03:05:33 +00:00
@@ -34,7 +34,7 @@ def create_project(ifc, project, schema=None, template=None):
|
|||||||
building = project.create_empty("My Building")
|
building = project.create_empty("My Building")
|
||||||
storey = project.create_empty("My Storey")
|
storey = project.create_empty("My Storey")
|
||||||
|
|
||||||
project.run_root_assign_class(obj=project_obj, ifc_class="IfcProject")
|
project.run_root_assign_class(obj=project_obj, ifc_class="IfcProject", should_add_representation=False)
|
||||||
project.run_unit_assign_scene_units()
|
project.run_unit_assign_scene_units()
|
||||||
|
|
||||||
model = project.run_context_add_context(context_type="Model", context_identifier="", target_view="", parent=0)
|
model = project.run_context_add_context(context_type="Model", context_identifier="", target_view="", parent=0)
|
||||||
|
|||||||
@@ -63,11 +63,15 @@ def assign_class(
|
|||||||
root: tool.Root,
|
root: tool.Root,
|
||||||
obj: bpy.types.Object,
|
obj: bpy.types.Object,
|
||||||
ifc_class: str,
|
ifc_class: str,
|
||||||
context: ifcopenshell.entity_instance,
|
context: Optional[ifcopenshell.entity_instance] = None,
|
||||||
predefined_type: Optional[str] = None,
|
predefined_type: Optional[str] = None,
|
||||||
should_add_representation: bool = True,
|
should_add_representation: bool = True,
|
||||||
ifc_representation_class: Optional[str] = None,
|
ifc_representation_class: Optional[str] = None,
|
||||||
) -> ifcopenshell.entity_instance:
|
) -> ifcopenshell.entity_instance:
|
||||||
|
"""
|
||||||
|
Args:
|
||||||
|
context: is not optional if `should_add_representation` is True
|
||||||
|
"""
|
||||||
if ifc.get_entity(obj):
|
if ifc.get_entity(obj):
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -77,6 +81,7 @@ def assign_class(
|
|||||||
ifc.link(element, obj)
|
ifc.link(element, obj)
|
||||||
|
|
||||||
if should_add_representation:
|
if should_add_representation:
|
||||||
|
assert context, "Context is required for adding a representation"
|
||||||
root.run_geometry_add_representation(
|
root.run_geometry_add_representation(
|
||||||
obj=obj, context=context, ifc_representation_class=ifc_representation_class, profile_set_usage=None
|
obj=obj, context=context, ifc_representation_class=ifc_representation_class, profile_set_usage=None
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ def hide_ports(ifc, system, element=None):
|
|||||||
def add_port(ifc, system, element=None):
|
def add_port(ifc, system, element=None):
|
||||||
system.load_ports(element, system.get_ports(element))
|
system.load_ports(element, system.get_ports(element))
|
||||||
obj = system.create_empty_at_cursor_with_element_orientation(element)
|
obj = system.create_empty_at_cursor_with_element_orientation(element)
|
||||||
port = system.run_root_assign_class(obj=obj, ifc_class="IfcDistributionPort")
|
port = system.run_root_assign_class(obj=obj, ifc_class="IfcDistributionPort", should_add_representation=False)
|
||||||
ifc.run("system.assign_port", element=element, port=port)
|
ifc.run("system.assign_port", element=element, port=port)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,9 @@ class TestCreateProject:
|
|||||||
project.create_empty("My Site").should_be_called().will_return("site")
|
project.create_empty("My Site").should_be_called().will_return("site")
|
||||||
project.create_empty("My Building").should_be_called().will_return("building")
|
project.create_empty("My Building").should_be_called().will_return("building")
|
||||||
project.create_empty("My Storey").should_be_called().will_return("storey")
|
project.create_empty("My Storey").should_be_called().will_return("storey")
|
||||||
project.run_root_assign_class(obj="project", ifc_class="IfcProject").should_be_called()
|
project.run_root_assign_class(
|
||||||
|
obj="project", ifc_class="IfcProject", should_add_representation=False
|
||||||
|
).should_be_called()
|
||||||
project.run_unit_assign_scene_units().should_be_called()
|
project.run_unit_assign_scene_units().should_be_called()
|
||||||
|
|
||||||
self.check_contexts(project)
|
self.check_contexts(project)
|
||||||
@@ -108,7 +110,9 @@ class TestCreateProject:
|
|||||||
project.create_empty("My Site").should_be_called().will_return("site")
|
project.create_empty("My Site").should_be_called().will_return("site")
|
||||||
project.create_empty("My Building").should_be_called().will_return("building")
|
project.create_empty("My Building").should_be_called().will_return("building")
|
||||||
project.create_empty("My Storey").should_be_called().will_return("storey")
|
project.create_empty("My Storey").should_be_called().will_return("storey")
|
||||||
project.run_root_assign_class(obj="project", ifc_class="IfcProject").should_be_called()
|
project.run_root_assign_class(
|
||||||
|
obj="project", ifc_class="IfcProject", should_add_representation=False
|
||||||
|
).should_be_called()
|
||||||
project.run_unit_assign_scene_units().should_be_called()
|
project.run_unit_assign_scene_units().should_be_called()
|
||||||
|
|
||||||
self.check_contexts(project)
|
self.check_contexts(project)
|
||||||
@@ -149,7 +153,9 @@ class TestCreateProject:
|
|||||||
project.create_empty("My Site").should_be_called().will_return("site")
|
project.create_empty("My Site").should_be_called().will_return("site")
|
||||||
project.create_empty("My Building").should_be_called().will_return("building")
|
project.create_empty("My Building").should_be_called().will_return("building")
|
||||||
project.create_empty("My Storey").should_be_called().will_return("storey")
|
project.create_empty("My Storey").should_be_called().will_return("storey")
|
||||||
project.run_root_assign_class(obj="project", ifc_class="IfcProject").should_be_called()
|
project.run_root_assign_class(
|
||||||
|
obj="project", ifc_class="IfcProject", should_add_representation=False
|
||||||
|
).should_be_called()
|
||||||
project.run_unit_assign_scene_units().should_be_called()
|
project.run_unit_assign_scene_units().should_be_called()
|
||||||
|
|
||||||
self.check_contexts(project)
|
self.check_contexts(project)
|
||||||
|
|||||||
@@ -146,7 +146,9 @@ class TestAddPort:
|
|||||||
system.get_ports("element").should_be_called().will_return(["port"])
|
system.get_ports("element").should_be_called().will_return(["port"])
|
||||||
system.load_ports("element", ["port"]).should_be_called()
|
system.load_ports("element", ["port"]).should_be_called()
|
||||||
system.create_empty_at_cursor_with_element_orientation("element").should_be_called().will_return("obj")
|
system.create_empty_at_cursor_with_element_orientation("element").should_be_called().will_return("obj")
|
||||||
system.run_root_assign_class(obj="obj", ifc_class="IfcDistributionPort").should_be_called().will_return("port")
|
system.run_root_assign_class(
|
||||||
|
obj="obj", ifc_class="IfcDistributionPort", should_add_representation=False
|
||||||
|
).should_be_called().will_return("port")
|
||||||
ifc.run("system.assign_port", element="element", port="port").should_be_called()
|
ifc.run("system.assign_port", element="element", port="port").should_be_called()
|
||||||
subject.add_port(ifc, system, element="element")
|
subject.add_port(ifc, system, element="element")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user