File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1074,6 +1074,7 @@ def get_absolute_matrix(cls, obj): pass
10741074@interface
10751075class System :
10761076 def create_empty_at_cursor_with_element_orientation (cls , element ): pass
1077+ def create_port_at_cursor (cls , system ): pass
10771078 def delete_element_objects (cls , elements ): pass
10781079 def disable_editing_system (cls ): pass
10791080 def disable_system_editing_ui (cls ): pass
Original file line number Diff line number Diff line change @@ -153,11 +153,10 @@ class TestAddPort:
153153 def test_run (self , ifc , system ):
154154 system .get_ports ("element" ).should_be_called ().will_return (["port" ])
155155 system .load_ports ("element" , ["port" ]).should_be_called ()
156- system .create_empty_at_cursor_with_element_orientation ("element" ).should_be_called ().will_return ("obj" )
157- system .run_root_assign_class (
158- obj = "obj" , ifc_class = "IfcDistributionPort" , should_add_representation = False
159- ).should_be_called ().will_return ("port" )
160- ifc .run ("system.assign_port" , element = "element" , port = "port" ).should_be_called ()
156+ #system.create_empty_at_cursor_with_element_orientation("element").should_be_called().will_return("obj")
157+ #system.run_root_assign_class(obj="obj", ifc_class="IfcDistributionPort", should_add_representation=False).should_be_called().will_return("port")
158+ system .create_port_at_cursor ("element" ).should_be_called ().will_return ("port" )
159+ system .load_ports ("element" , ["port" ]).should_be_called ()
161160 subject .add_port (ifc , system , element = "element" )
162161
163162
Original file line number Diff line number Diff line change @@ -103,6 +103,19 @@ def test_run(self):
103103 obj = subject .create_empty_at_cursor_with_element_orientation (element )
104104 assert obj .matrix_world == bpy .context .scene .cursor .matrix
105105
106+ class TestCreatePortAtCursor (NewFile ):
107+ def test_run (self ):
108+ assert bpy .context .scene
109+ ifc = ifcopenshell .file ()
110+ tool .Ifc ().set (ifc )
111+ system = ifcopenshell .api .system .add_system (ifc )
112+ element = ifcopenshell .api .root .create_entity (ifc , ifc_class = "IfcDuctSegment" )
113+ ifcopenshell .api .system .assign_system (ifc , products = [element ], system = system )
114+ obj = tool .Ifc .link (element , bpy .data .objects .new ("Object" , None ))
115+ port = subject .create_port_at_cursor (element )
116+ assert port .is_a ("IfcDistributionPort" )
117+ assert ifcopenshell .util .system .get_ports (element ) == [port ]
118+
106119
107120class TestDeleteElementObjects (NewFile ):
108121 def test_run (self ):
You can’t perform that action at this time.
0 commit comments