mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 09:48:41 +00:00
Fix #2999. You can now edit topology representation items.
This commit is contained in:
@@ -2190,7 +2190,9 @@ class OverrideModeSetObject(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
item = tool.Geometry.get_active_representation(obj)
|
item = tool.Geometry.get_active_representation(obj)
|
||||||
assert item
|
assert item
|
||||||
if tool.Geometry.is_meshlike_item(item):
|
if tool.Geometry.is_meshlike_item(item):
|
||||||
if tool.Geometry.is_geometric_data(obj.data) and obj.data.polygons:
|
if tool.Geometry.is_geometric_data(obj.data) and (
|
||||||
|
item.is_a("IfcVertex") or item.is_a("IfcEdge") or obj.data.polygons
|
||||||
|
):
|
||||||
tool.Geometry.edit_meshlike_item(obj)
|
tool.Geometry.edit_meshlike_item(obj)
|
||||||
else:
|
else:
|
||||||
tool.Geometry.import_item(obj)
|
tool.Geometry.import_item(obj)
|
||||||
|
|||||||
@@ -1014,7 +1014,13 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_meshlike_item(cls, item: ifcopenshell.entity_instance) -> bool:
|
def is_meshlike_item(cls, item: ifcopenshell.entity_instance) -> bool:
|
||||||
return item.is_a("IfcTessellatedItem") or item.is_a("IfcManifoldSolidBrep")
|
return (
|
||||||
|
item.is_a("IfcTessellatedItem")
|
||||||
|
or item.is_a("IfcManifoldSolidBrep")
|
||||||
|
or item.is_a("IfcVertex")
|
||||||
|
or item.is_a("IfcEdge")
|
||||||
|
or item.is_a("IfcFace")
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_curvelike_item(cls, item: ifcopenshell.entity_instance) -> bool:
|
def is_curvelike_item(cls, item: ifcopenshell.entity_instance) -> bool:
|
||||||
@@ -1824,6 +1830,9 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
position = Matrix(ifcopenshell.util.placement.get_axis2placement(position).tolist())
|
position = Matrix(ifcopenshell.util.placement.get_axis2placement(position).tolist())
|
||||||
position.translation *= unit_scale
|
position.translation *= unit_scale
|
||||||
obj.matrix_world = rep_obj.matrix_world @ position
|
obj.matrix_world = rep_obj.matrix_world @ position
|
||||||
|
elif item.is_a("IfcVertex"):
|
||||||
|
co = np.array(item.VertexGeometry.Coordinates) * ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
|
obj.data.from_pydata([co], [], [])
|
||||||
else:
|
else:
|
||||||
geometry = tool.Loader.create_generic_shape(item)
|
geometry = tool.Loader.create_generic_shape(item)
|
||||||
verts = ifcopenshell.util.shape.get_vertices(geometry)
|
verts = ifcopenshell.util.shape.get_vertices(geometry)
|
||||||
@@ -1901,6 +1910,12 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
faces = [p.vertices[:] for p in obj.data.polygons]
|
faces = [p.vertices[:] for p in obj.data.polygons]
|
||||||
if item.is_a("IfcAdvancedBrep"):
|
if item.is_a("IfcAdvancedBrep"):
|
||||||
new_item = builder.faceted_brep(verts, faces)
|
new_item = builder.faceted_brep(verts, faces)
|
||||||
|
elif item.is_a("IfcVertex"):
|
||||||
|
new_item = builder.vertex(verts[0])
|
||||||
|
elif item.is_a("IfcEdge"):
|
||||||
|
new_item = builder.edge(start=verts[0], end=verts[1])
|
||||||
|
elif item.is_a("IfcFace"):
|
||||||
|
new_item = builder.face([verts[i] for i in faces[0]])
|
||||||
else:
|
else:
|
||||||
new_item = builder.mesh(verts, faces)
|
new_item = builder.mesh(verts, faces)
|
||||||
for inverse in tool.Ifc.get().get_inverse(item):
|
for inverse in tool.Ifc.get().get_inverse(item):
|
||||||
|
|||||||
@@ -802,8 +802,7 @@ class Loader(bonsai.core.tool.Loader):
|
|||||||
print(f"WARNING. Unsupported point type for IfcStructuralPointConnection: {point}.")
|
print(f"WARNING. Unsupported point type for IfcStructuralPointConnection: {point}.")
|
||||||
return
|
return
|
||||||
|
|
||||||
ifc_file = tool.Ifc.get()
|
co = np.array(point.Coordinates) * ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
co = np.array(point.Coordinates) * ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
|
|
||||||
mesh_name = tool.Geometry.get_representation_name(representation)
|
mesh_name = tool.Geometry.get_representation_name(representation)
|
||||||
mesh = bpy.data.meshes.new(mesh_name)
|
mesh = bpy.data.meshes.new(mesh_name)
|
||||||
mesh.from_pydata([co], [], [])
|
mesh.from_pydata([co], [], [])
|
||||||
|
|||||||
Reference in New Issue
Block a user