Linking surfaces into point models
Linking surfaces with point models is an useful way to get initial orientations of particles. The idea is to assign to each crop_point in the general model a crop_angle that is defined with reference to the support surface. Mathematically, Dynamo locates the closest triangle in the triangulation of the supporting surface, reads the normal, and formats it to provide the three euler angles needed to crop a particle.
Command line
Let's assume you have to models in your workspace: p is a general point model, and s is a surface model (for instance of class membraneByLevels)
Make certain that s contains already a depiction triangulation. This is created with the black triangle icon in the workflow for surfaces, or with the method createMesh from the command line.
Note that you can check visually the orientations of the particles in the model through the commands
p.plotTableSketch([],'hold_limits',false);
which will show by default orientations pointing upward.
You can directly link the mesh inside surface s into points p by:
p.linkedSurface = s.mesh
After running this assignment the model p will be able to recompute its crop_angles with reference to its linked surface by:
p.cropAnglesFromLinkedSurface();
Linking filaments
This technique can also be used to set orientations defined as normals from a filament. In this case, for a filament model f, the linkage is performed through:
p.linkedBackbone = f.backbone