mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-17 10:59:17 +00:00
Port locations now sync relative to their parent even when not actively displayed in the viewport
This commit is contained in:
@@ -110,11 +110,9 @@ class MepGenerator:
|
||||
end_port_matrix = Matrix.Translation((0, 0, self.length))
|
||||
|
||||
for mat in [start_port_matrix, end_port_matrix]:
|
||||
port_obj = bpy.data.objects.new("Port", None)
|
||||
port_obj.matrix_world = mat
|
||||
port_obj.parent = obj
|
||||
port = tool.System.run_root_assign_class(obj=port_obj, ifc_class="IfcDistributionPort")
|
||||
port = tool.Ifc.run("root.create_entity", ifc_class="IfcDistributionPort")
|
||||
tool.Ifc.run("system.assign_port", element=element, port=port)
|
||||
tool.Ifc.run("geometry.edit_object_placement", product=port, matrix=obj.matrix_world @ mat, is_si=True)
|
||||
|
||||
obj.select_set(True)
|
||||
return obj
|
||||
|
||||
@@ -142,11 +142,10 @@ class AddTypeInstance(bpy.types.Operator):
|
||||
mat[0][3] *= unit_scale
|
||||
mat[1][3] *= unit_scale
|
||||
mat[2][3] *= unit_scale
|
||||
port_obj = bpy.data.objects.new("Port", None)
|
||||
port_obj.matrix_world = mathutils.Matrix(mat)
|
||||
port_obj.parent = obj
|
||||
port = tool.System.run_root_assign_class(obj=port_obj, ifc_class="IfcDistributionPort")
|
||||
tool.Ifc.run("system.assign_port", element=element, port=port)
|
||||
mat = obj.matrix_world @ mathutils.Matrix(mat)
|
||||
new_port = tool.Ifc.run("root.create_entity", ifc_class="IfcDistributionPort")
|
||||
tool.Ifc.run("system.assign_port", element=element, port=new_port)
|
||||
tool.Ifc.run("geometry.edit_object_placement", product=new_port, matrix=mat, is_si=True)
|
||||
|
||||
bpy.ops.object.select_all(action="DESELECT")
|
||||
obj.select_set(True)
|
||||
|
||||
@@ -140,7 +140,7 @@ class ShowPorts(bpy.types.Operator, Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def _execute(self, context):
|
||||
core.show_ports(tool.System, element=tool.Ifc.get_entity(context.active_object))
|
||||
core.show_ports(tool.Ifc, tool.System, element=tool.Ifc.get_entity(context.active_object))
|
||||
|
||||
|
||||
class HidePorts(bpy.types.Operator, Operator):
|
||||
|
||||
@@ -21,11 +21,12 @@ import blenderbim.core.style
|
||||
|
||||
def edit_object_placement(ifc, geometry, surveyor, obj=None):
|
||||
element = ifc.get_entity(obj)
|
||||
if element:
|
||||
geometry.clear_cache(element)
|
||||
geometry.clear_scale(obj)
|
||||
ifc.run("geometry.edit_object_placement", product=element, matrix=surveyor.get_absolute_matrix(obj))
|
||||
geometry.record_object_position(obj)
|
||||
if not element:
|
||||
return
|
||||
geometry.clear_cache(element)
|
||||
geometry.clear_scale(obj)
|
||||
ifc.run("geometry.edit_object_placement", product=element, matrix=surveyor.get_absolute_matrix(obj))
|
||||
geometry.record_object_position(obj)
|
||||
|
||||
|
||||
def add_representation(
|
||||
|
||||
@@ -66,7 +66,11 @@ def select_system_products(system_tool, system=None):
|
||||
system_tool.select_system_products(system)
|
||||
|
||||
|
||||
def show_ports(system, element=None):
|
||||
def show_ports(ifc, system, element=None):
|
||||
obj = ifc.get_object(element)
|
||||
if obj and ifc.is_moved(obj):
|
||||
system.run_geometry_edit_object_placement(obj=obj)
|
||||
|
||||
ports = system.get_ports(element)
|
||||
system.load_ports(element, ports)
|
||||
system.select_elements(ports)
|
||||
|
||||
@@ -65,8 +65,8 @@ the **Navigate Gizmo**.
|
||||
.. image:: navigate-gizmo.png
|
||||
|
||||
You can also use your mouse to navigate. Hover your mouse over the **Viewport**
|
||||
panel and click and drag the Middle Mouse Button (MMB) to **Orbit**. Scroll the
|
||||
mousewheel to **Zoom**, and use Shift-MMB to **Pan**.
|
||||
panel and click and drag the Middle Mouse Button (``MMB``) to **Orbit**. Scroll
|
||||
the mousewheel to **Zoom**, and use ``Shift-MMB`` to **Pan**.
|
||||
|
||||
If you have a numpad, you can use the numpad keys to quickly switch to top,
|
||||
front, or side view. Use ``7`` for top view, ``1`` for front view, and ``3`` for
|
||||
|
||||
@@ -91,11 +91,15 @@ class TestSelectSystemProducts:
|
||||
|
||||
|
||||
class TestShowPorts:
|
||||
def test_run(self, system):
|
||||
def test_run(self, ifc, system):
|
||||
ifc.get_object("element").should_be_called().will_return("obj")
|
||||
ifc.is_moved("obj").should_be_called().will_return(True)
|
||||
system.run_geometry_edit_object_placement(obj="obj").should_be_called()
|
||||
|
||||
system.get_ports("element").should_be_called().will_return(["port"])
|
||||
system.load_ports("element", ["port"]).should_be_called()
|
||||
system.select_elements(["port"]).should_be_called()
|
||||
subject.show_ports(system, element="element")
|
||||
subject.show_ports(ifc, system, element="element")
|
||||
|
||||
|
||||
class TestHidePorts:
|
||||
|
||||
Reference in New Issue
Block a user