BTW @andrej730 that optimisation is awesome. Here's a timeit:
import bpy
import numpy as np
import timeit
obj = bpy.context.active_object
verts = obj.data.vertices
def foreach_get_method():
coords = np.empty(len(verts) * 3, dtype=np.float32)
obj.data.vertices.foreach_get("co", coords)
coords = coords.reshape(-1, 3)
coords = coords.astype("d")
coords /= 10
return coords
def list_comprehension_method():
coords = [v.co / 10 for v in verts]
return coords
# Number of times each function will be executed
num_runs = 10000
t_listcomp = timeit.timeit(list_comprehension_method, number=num_runs)
t_foreach = timeit.timeit(foreach_get_method, number=num_runs)
print("foreach method: {:.6f} seconds over {} runs".format(t_foreach,
num_runs))
print("List comprehension method: {:.6f} seconds over {}
runs".format(t_listcomp, num_runs))
# foreach method: 0.088656 seconds over 10000 runs
# List comprehension method: 0.644446 seconds over 10000 runs
IfcOpenShell
IfcOpenShell is an open source (LGPL) software library for working with Industry Foundation Classes (IFC). Complete parsing support is provided for IFC2x3 TC1, IFC4 Add2 TC1, IFC4x1, IFC4x2, and IFC4x3 Add2. Extensive geometric support is implemented for the IFC releases IFC2x3 TC1 and IFC4 Add2 TC1. Extending with support for arbitrary IFC schemas is possible at compile-time when using C++ and at run-time when using Python.
In addition to a C++ and Python API, IfcOpenShell comes with an ecosystem of tools, notably including IfcConvert (an application to convert IFC models to other formats), Bonsai (an add-on to Blender providing a graphical IFC authoring platform), and many other libraries, CLI apps, and more. Support is also provided for auxiliary standards such as BCF and IDS.
For more information, see:
Development is sponsored through your generous donations!
Contents
The IfcOpenShell C++ codebase is split into multiple interal libraries:
| Name | Description | License |
|---|---|---|
| ifcgeom | Internal library for IfcOpenShell | LGPL-3.0-or-later* |
| ifcgeom_schema_agnostic | Internal library for IfcOpenShell | LGPL-3.0-or-later* |
| ifcgeomserver | Internal library for IfcOpenShell | LGPL-3.0-or-later* |
| ifcjni | Internal library for IfcOpenShell | LGPL-3.0-or-later* |
| ifcparse | Internal library for IfcOpenShell | LGPL-3.0-or-later* |
| ifcwrap | Internal library for IfcOpenShell | LGPL-3.0-or-later* |
| qtviewer | Internal library for IfcOpenShell | LGPL-3.0-or-later* |
| serializers | Internal library for IfcOpenShell | LGPL-3.0-or-later* |