Get CurveLoop Center point

Get CurveLoop Center point

Ali.sadeghi.h1994
Enthusiast Enthusiast
1,048 Views
6 Replies
Message 1 of 7

Get CurveLoop Center point

Ali.sadeghi.h1994
Enthusiast
Enthusiast

Hi everyone.

Does someone know how to get center point of a CurveLoop?

I have a list consists of all openings  Curveloop on a floor and I want to put an instance exactly on center of Curveloop.

0 Likes
Accepted solutions (1)
1,049 Views
6 Replies
Replies (6)
Message 2 of 7

AGGilliam
Collaborator
Collaborator
Accepted solution
Not sure of any direct methods, but what I've done is loop through the curves to add up all of the points, then divide by the number of points. For example, ((0,0) + (0,2) + (2,0) + (2,2)) / 4 = (1,1).
Message 3 of 7

jeremy_tammik
Alumni
Alumni

Use an algorithm to find the centre of a polygon:

  

https://duckduckgo.com/?q=center+polygon

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 4 of 7

Ali.sadeghi.h1994
Enthusiast
Enthusiast
Thank you. That's a good idea and I have used that and it works well. But There is still an exception in my code that is existing of a curveloop with circle shape in my Revit model. If you have an idea to solve this exception, I will be happy to let me know.
0 Likes
Message 5 of 7

Ali.sadeghi.h1994
Enthusiast
Enthusiast
Thanks for all of your guides and I'm glad that you answered my question.
The exception is existing an opening on floor with circular shape and the algorithm won't give the centroid. I need center point of all openings in any form on floors. If you know other ways to get that, I will be happy to know.
Message 6 of 7

AGGilliam
Collaborator
Collaborator
Ah, in that case, when you loop through the curves in the curveloop you can check for Arcs or Ellipses and use the Center property to get it.
0 Likes
Message 7 of 7

Ali.sadeghi.h1994
Enthusiast
Enthusiast

Thanks for your solutions.

I will try that.

0 Likes