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.
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.
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}, "
Or you can use "/" (inspired by how pathlib concatenates paths).
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()
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
[x for x in dir(p) if x.startswith("to_")]
['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.
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
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.
[x for x in dir(a) if x.startswith("to_")]
['to_fem', 'to_fem_obj', 'to_genie_xml', 'to_gltf', 'to_ifc', 'to_obj_mesh', 'to_stp', 'to_trimesh_scene']