This page was generated from doc/documents/notebooks/parts_and_assemblies.ipynb.
Interactive online version: Binder badge - Download notebook - Or view it on nbviewer.

Parts and Assemblies

In ada-py the Part and Assembly objects are used to define the hierarchy of elements. Assembly is the top-level object referenced only once per project, while the Part object is used to represent all hierarchical levels underneath the Assembly.

[1]:
import ada

In ada-py there are two ways to add objects to a Part. You can use the add_object method or you can use the / operator.

[2]:
bm = ada.Beam("bm1", (0,0,0), (1,0,0), 'IPE300')
pl = ada.Plate('pl1', [(0,0), (1,0), (1,1), (0,1)], 0.01)
p = ada.Part('myPart')
p.add_object(bm)
p.add_object(pl)
p.show()
C:\AibelProgs\code\adapy\.pixi\envs\tests\Lib\site-packages\h5py\__init__.py:36: UserWarning: h5py is running against HDF5 (1, 14, 4) when it was built against (1, 14, 4, 3), this may cause problems
  _warn(("h5py is running against HDF5 {0} when it was built against {1}, "
[2]:

Or you can use “/” (inspired by how pathlib concatenates paths).

[3]:
bm = ada.Beam("bm1", (0,0,0), (1,0,0), 'IPE300')
pl = ada.Plate('pl1', [(0,0), (1,0), (1,1), (0,1)], 0.01)
p = ada.Part('MyPart') / (bm, pl)
p.show()
[3]:

You are free to nest parts to you like to create a hierarchy of elements.

You’ll notice that there are several methods available on the Part object to export it to different formats

[4]:
[x for x in dir(p) if x.startswith("to_")]
[4]:
['to_fem',
 'to_fem_obj',
 'to_gltf',
 'to_obj_mesh',
 'to_stp',
 'to_trimesh_scene']

However, if you want to export to formats such as IFC, you’ll have to add a top-level Assembly object to your project. The Assembly object is the top-level object in the hierarchy and is used to define the project. It is as subclass of Part, but it is referenced only once per project.

[5]:
a = ada.Assembly('myAssembly') / p
a.show()
Note: API not available due to missing dependencies: geometry.add_door_representation - No module named 'mathutils'
Note: API not available due to missing dependencies: geometry.add_railing_representation - No module named 'mathutils'
Note: API not available due to missing dependencies: geometry.add_representation - No module named 'bpy'
Note: API not available due to missing dependencies: geometry.add_window_representation - No module named 'mathutils'
Note: API not available due to missing dependencies: grid.create_axis_curve - No module named 'mathutils'
Sync Complete. Added 2 objects and 1 spatial elements. Modified 0 objects. Deleted 0 objects
[5]:

You’ll see that the Assembly object has 2 additional methods to export to IFC and genie_xml formats (Genie XML is the format used by a Finite element pre/post-processor Genie which is part of the Sesam suite by DNV.

[6]:
[x for x in dir(a) if x.startswith("to_")]
[6]:
['to_fem',
 'to_fem_obj',
 'to_genie_xml',
 'to_gltf',
 'to_ifc',
 'to_obj_mesh',
 'to_stp',
 'to_trimesh_scene']