mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 14:22:33 +00:00
black .
This commit is contained in:
@@ -112,20 +112,20 @@ class System(bonsai.core.tool.System):
|
||||
def create_port_at_cursor(cls, element: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
|
||||
ifc_file = tool.Ifc.get()
|
||||
element_obj = tool.Ifc.get_object(element)
|
||||
|
||||
|
||||
port = ifcopenshell.api.system.add_port(ifc_file, element=element)
|
||||
port.FlowDirection = "NOTDEFINED"
|
||||
port.PredefinedType = "USERDEFINED"
|
||||
|
||||
|
||||
systems = ifcopenshell.util.system.get_element_systems(element)
|
||||
system = systems[0] if systems else None
|
||||
port.SystemType = getattr(system, "PredefinedType", None) or "USERDEFINED"
|
||||
|
||||
|
||||
matrix = element_obj.matrix_world.copy()
|
||||
matrix.translation = bpy.context.scene.cursor.matrix.translation
|
||||
|
||||
|
||||
ifcopenshell.api.geometry.edit_object_placement(ifc_file, product=port, matrix=matrix, is_si=True)
|
||||
|
||||
|
||||
return port
|
||||
|
||||
@classmethod
|
||||
@@ -218,7 +218,7 @@ class System(bonsai.core.tool.System):
|
||||
for collection in obj.users_collection:
|
||||
target_collection = collection
|
||||
break
|
||||
|
||||
|
||||
if target_collection:
|
||||
for port_obj in ifc_importer.added_data.values():
|
||||
if isinstance(port_obj, bpy.types.Object):
|
||||
|
||||
@@ -153,8 +153,8 @@ class TestAddPort:
|
||||
def test_run(self, ifc, system):
|
||||
system.get_ports("element").should_be_called().will_return(["port"])
|
||||
system.load_ports("element", ["port"]).should_be_called()
|
||||
#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_add_representation=False).should_be_called().will_return("port")
|
||||
# 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_add_representation=False).should_be_called().will_return("port")
|
||||
system.create_port_at_cursor("element").should_be_called().will_return("port")
|
||||
system.load_ports("element", ["port"]).should_be_called()
|
||||
subject.add_port(ifc, system, element="element")
|
||||
|
||||
@@ -103,6 +103,7 @@ class TestCreateEmptyAtCursorWithElementOrientation(NewFile):
|
||||
obj = subject.create_empty_at_cursor_with_element_orientation(element)
|
||||
assert obj.matrix_world == bpy.context.scene.cursor.matrix
|
||||
|
||||
|
||||
class TestCreatePortAtCursor(NewFile):
|
||||
def test_run(self):
|
||||
assert bpy.context.scene
|
||||
|
||||
Reference in New Issue
Block a user