Filtering a family by angle

Hello everyone

I’m trying to make a dynamo script that would help me rotate my pipe hangers to be aligned with the pipe

1-Script
2-Model
3-Model after running the script

When running my script the horizontal pipes and hangers get aligned perfectly, however the pipe on the left is running with a 45 degree angle so I’m wondering if I can create a filter around such angles so I’m able to set a different angle rotation for the hangers on the rotated pipe?.

May be telling you something that you already know. Compare the angle of the pipe to either x or y project axis to get its angle. Then compare the orientation of the hanger to the same x or y project axis to get its angle. Then compare both angles and do the math to know if the hanger needs to be rotated and by how much. You will need to sort/group the pipes with their corresponding hangers to make sure you are rotating the correct hangers.

EDIT
One way to get angle of piping

Hello thanks a lot for helping

if I may ask where can I get the Element.LocationCurve node from?

Genius Loci package has it. See what you can come up with and if you get stuck on anything, post a sample of your project along with what you have done with your script and we can help from there.

Alright so I have come to the point where I can select each pipe and then select the hangers associated with that pipe and run the script, however I can’t find a node where I can tie the angle between the hanger and the pipe.
unfortunately the Genius loci node only works on pipes and would not allow me to get the angle of the pipe hangers with the X axis vector

again thanks a lot for the help but sadly as a new user I can not upload attachments yet

here is the script up to this point

No worries.

Genius Loci has another node called “Element.GetRotation”. Which if I understand correctly, uses the project BasisX also for getting the rotation angle. You will need to do some testing to verify.

I don’t believe that node works on piping, so you will need to keep using the same method for getting their rotation angles.

After you get this script to work, I would try to incorporate it into the one that you are using to place the hangers and have it automatically rotate them at the same time.