Reimplement edge based mesh import

We don't use foreach_set, since for some reason doing it with foreach_set requires edit mode to be toggled for the edges to be visible. We make the assumption that an object is either edge based or face based, but not both.
This commit is contained in:
Dion Moult
2020-06-21 09:48:54 +10:00
parent a931c5ced9
commit 358d9ef1c8
3 changed files with 26 additions and 18 deletions
@@ -1671,23 +1671,30 @@ class IfcImporter():
mesh = bpy.data.meshes.new(geometry.id)
vertices = geometry.verts
num_vertices = len(vertices) // 3
vertex_index = geometry.faces
total_faces = len(geometry.faces)
loop_start = range(0, total_faces, 3)
num_loops = total_faces // 3
loop_total = [3] * num_loops
num_vertex_indices = len(vertex_index)
if geometry.faces:
num_vertices = len(geometry.verts) // 3
total_faces = len(geometry.faces)
loop_start = range(0, total_faces, 3)
num_loops = total_faces // 3
loop_total = [3] * num_loops
num_vertex_indices = len(geometry.faces)
mesh.vertices.add(num_vertices)
mesh.vertices.foreach_set('co', vertices)
mesh.loops.add(num_vertex_indices)
mesh.loops.foreach_set('vertex_index', vertex_index)
mesh.polygons.add(num_loops)
mesh.polygons.foreach_set('loop_start', loop_start)
mesh.polygons.foreach_set('loop_total', loop_total)
mesh.update()
mesh.vertices.add(num_vertices)
mesh.vertices.foreach_set('co', geometry.verts)
mesh.loops.add(num_vertex_indices)
mesh.loops.foreach_set('vertex_index', geometry.faces)
mesh.polygons.add(num_loops)
mesh.polygons.foreach_set('loop_start', loop_start)
mesh.polygons.foreach_set('loop_total', loop_total)
mesh.update()
else:
e = geometry.edges
v = geometry.verts
vertices = [[v[i], v[i + 1], v[i + 2]]
for i in range(0, len(v), 3)]
edges = [[e[i], e[i + 1]]
for i in range(0, len(e), 2)]
mesh.from_pydata(vertices, edges, [])
ios_materials = []
for mat in geometry.materials:
+1 -1
View File
@@ -1082,7 +1082,7 @@ class RepresentationItem(PropertyGroup):
class BIMMeshProperties(PropertyGroup):
is_wireframe: BoolProperty(name="Is Wireframe")
is_native: BoolProperty(name="Is Native")
is_native: BoolProperty(name="Is Native", default=False)
is_swept_solid: BoolProperty(name="Is Swept Solid")
swept_solids: CollectionProperty(name="Swept Solids", type=SweptSolid)
is_parametric: BoolProperty(name='Is Parametric', default=False)
+2 -1
View File
@@ -846,7 +846,8 @@ class BIM_PT_bim(Panel):
row = layout.row()
row.prop(bim_properties, "ifc_userdefined_type")
row = layout.row()
row.operator("bim.assign_class")
op = row.operator("bim.assign_class")
op.object_name = ''
row = layout.row(align=True)
row.operator("bim.select_class")