Rotate family instances based on line direction angle

Hello everyone, i need help about rotating family instance based on line direction angle.

I am trying to make a safety line to rounding a pile cap through dynamo
So, i did the following. but, the results is not what i expected. I know theres something that im missing cause this maybe a very common use.

so steps i already did is:

  1. make a rectangle with curves arounding the pile cap
  2. get the start point of the 4 sides lines and places the safety line at those point ( the point is located all the edges)
  3. from the rectangle curves, get all the Line.direction, and connect it with Vector.AngleWithVector and get the degree value.
  4. FamilyInstance.SetRotation connected with the safety lines family and the degree value

heres the nodes and the results is:

what i expect to happen is, the last safety cables should have close the rectangle and , rounding the pile cap

How do i to achieve that?

Thankyou very much!

I believe AngleWithVector finds the relative angle, so it only goes up to 180 degrees. You would also have to take into account the directionality of the line to know whether it’s a positive or negative 90.

1 Like

You could make a cable box family and have parameters control the size of the box and the height of the cables. Have the origin/insertion point set to the center/bottom of the cable box. Then use FamilyInstance.ByPoint to place cable box family. The insertion points would be the intersection of the column and the top of the slab, which it looks like you are already getting. From that point it would be just a matter of setting the rotation of the cable box family to align with the slab edge or however you want it. Just a thought, that may prove easier.

1 Like

Vector.AngleAboutAxis for the win!

3 Likes

It works perfectly !!
Thankyou so much

1 Like