How get previous and next element rotation and loop for all

With limited Dynamo knowledge, I wish someone can teach me or tell me which node can be use for the clashed problem.
How can I check the clashed object (as attached) and get its previous ‘element get rotation’ and next ‘element get rotation’? I wish to set a new rotation for the clashed one (by getting the average of 2 rotations obtained) and do it for all the clashed.
Thanks!capture11

@Frederic,
do we have ordered objects?
image

they are placed by another dynamo script and should have consecutive ID, but as only the clashed ones need to be selected and find the previous one and next one’s rotation to get the average and set the new rotation.
Thanks a lot for your advice.

@Frederic,
share your RVT an DYN files, we’ll try.

test.rvt (1.5 MB) As attached. Really much appreciated for kindly help!
test_10.dyn (6.0 KB)

@Frederic,

Can you analyze perfect case? Maybe we can have one central point, points on first spline (numerated with red color) and we’ll orient families with vectors (from central point to 1…10 points)?
So, wee need to rebuild your first dynamo step.

Thanks for reply Vladimir. But not suitable for my cases as they are along topography surface.
I got stuck at the steps to update the clashed ones which thinking to update the familyinstance by adding 5 degree increment each time to its original orientation. (max. adjust 20 degree or warn the users).
I tried so many times to add a whileloop but still failed at this moment. :frowning:

@Frederic,

  1. Place families manually as good as you can.
  2. Show and share with us with part of topography surface.
  3. We’ll try to find out right approach (if it can be algorithmic).

I’m afraid the topo cannot be shared which created by C3D.
By the way, I have questions:

  1. hopefully to know how to loop the familyinstance.setrotation by providing a clashed list of elements by trying to adjust a given degree at a time. I have searched loopwhile from internet by not really clear how it works properly in my case :pensive:
  2. any node in c3d dynamo to place revit family? or I have to convert family to dynamic block?
    Much thankful!