#!/usr/bin/env python # coding: utf-8 # # 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. # # In[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. # In[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() # Or you can use "/" (inspired by how pathlib concatenates paths). # In[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() # 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 # In[4]: [x for x in dir(p) if x.startswith("to_")] # 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. # In[5]: a = ada.Assembly('myAssembly') / p a.show() # 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. # In[6]: [x for x in dir(a) if x.startswith("to_")]