Fix #2999. You can now edit topology representation items.

This commit is contained in:
Dion Moult
2025-05-26 12:41:55 +10:00
parent 242d70c311
commit d6cc1ff9e9
3 changed files with 20 additions and 4 deletions
@@ -2190,7 +2190,9 @@ class OverrideModeSetObject(bpy.types.Operator, tool.Ifc.Operator):
item = tool.Geometry.get_active_representation(obj)
assert 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)
else:
tool.Geometry.import_item(obj)
+16 -1
View File
@@ -1014,7 +1014,13 @@ class Geometry(bonsai.core.tool.Geometry):
@classmethod
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
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.translation *= unit_scale
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:
geometry = tool.Loader.create_generic_shape(item)
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]
if item.is_a("IfcAdvancedBrep"):
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:
new_item = builder.mesh(verts, faces)
for inverse in tool.Ifc.get().get_inverse(item):
+1 -2
View File
@@ -802,8 +802,7 @@ class Loader(bonsai.core.tool.Loader):
print(f"WARNING. Unsupported point type for IfcStructuralPointConnection: {point}.")
return
ifc_file = tool.Ifc.get()
co = np.array(point.Coordinates) * ifcopenshell.util.unit.calculate_unit_scale(ifc_file)
co = np.array(point.Coordinates) * ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
mesh_name = tool.Geometry.get_representation_name(representation)
mesh = bpy.data.meshes.new(mesh_name)
mesh.from_pydata([co], [], [])