# Animation nodes, instances orientation in a Dodecahedron

I'm trying to orient instances so that they align correctly to form same shape of the Mesh Object Input, here a pentagonal faces Dodecahedron. I've used Vertex Group Input to control the Guides param. of Direction to Rotation node, but it's a kind of dirty trick, not perfect clean math solution at all.How to orient instances correctly? blend file

This method works for any object which has symmetric faces of the same size. The main idea is to align the instance object's (in your case the Tritube) any axis (local) along the edges of the base object (in your case is the Pentaface).

Note: This method required that any symmetric face of the base object should not have any cutting edge. For example, a cube object should not have a diagonal edge in any its face or in case of Pentaface object:

Step-1: A edge has a start, end, and center. So, the equation below gives the guide for start and end:

Start-Center = guide at the start
End-Center = guide at the end


To solve this for all edges, I have made a Guides for Direction Loop loop-node which takes the vertex locations, edges of the object and two empty vector lists, calculate the guides for each vertex. To simplify further, I have also made a AN-Guides for Direction group-node which automatically creates two empty lists for the Guides for Direction Loop node, so you only need to supply the vertex locations and edges:

Step-2: Then connect the vertex normals to direction and guides from the AN-Guides for Direction group-node to guides of the Direction to Rotation node: Sometimes, you may need to rotate the instance object (in your case the Tritube) in edit mode to match the direction of the edges of the base object.

Step-3: Here is an example for cube object but same node-tree:

Step-4: I have converted the node-tree of How to call vertex groups in Animation nodes into a group-node for easy usage:

Step-5: Now, you can easily change the z-direction of instances with vertex weight but keeping them align with the edges of the base object with this node-tree:

Complete Node-Tree:

Blend File:

• Yes, pure gold! I doubt someone has a better way to do it. I'm try to see in depth what's going on Guides for Direction Loop, to better understand it. In the meanwhile i discovered it seems not work with IcoSphere mesh, it's triangle faces that causes issues? link - Thanks! – mike Nov 16 '19 at 20:49
• Your welcome. Yes, I know that because it does not has symmetric faces of equal size (also mentioned in the answer). However, aligning instances per edge is easy and possible for any object of any shape. But I'll update this answer when I find a method that works for any object. – 3DSinghVFX Nov 17 '19 at 4:55