How to create ellipse curve?

How to create ellipse curve?

Anonymous
Not applicable
2,529 Views
6 Replies
Message 1 of 7

How to create ellipse curve?

Anonymous
Not applicable

Hello! 

I have 2 points (A and B) on ellipse curve and ellipse curve. I want to create ellipse curve from point A to point B. 

Any ideas how to do it? 

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

jeremytammik
Autodesk
Autodesk

You will need more detailed information to create the elliptical curve. Just two points is insufficiently specific. Please read the Revit API documentation and some basic geometric information about ellipse properties and calculations:

 

Revit API elliptical curve constructor:

 

https://www.revitapidocs.com/2020/a3da8ed5-5fea-087f-6989-c987ce7ae47f.htm

 

Basic properties of ellipses:

 

https://en.wikipedia.org/wiki/Ellipse

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 7

Revitalizer
Advisor
Advisor
Accepted solution

Hi Jeremy,

 

he says:

"I have 2 points (A and B) on ellipse curve and ellipse curve."

 

So in fact he could just hand over the original Ellipse's properties to the new Ellipse's constructor.

Thus, only the startParameter and endParameter values are to be calculated.

 

I think there are at least two ways to get there.

 

First, use originalEllipse.Project(firstPoint).Parameter

 

Second, create a line by the two points.

Intersect line and originalEllipse.

The intersection result also provides the parameter.

 

Both the constructor and the Project/Intersect methods use raw parameters, so I think the values can be used without originalEllipse.ComputeNormalizedParameter() in between.

 

Ah, of course the two points define two possible elliptical segments.

One could create both (by switching start and end parameters?) and choose the shorter one 😉

 

Rudi

 

 




Rudolf Honke
Software Developer
Mensch und Maschine





Message 4 of 7

jeremytammik
Autodesk
Autodesk

I love your suggestion. You read the question more carefully than I did. Looking forward to hearing a response to this. I wish you and all readers a wonderful weekend!

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 7

Anonymous
Not applicable

Thank you. All work!

I'm a girl  😉

Please, help me to another question: 

https://forums.autodesk.com/t5/revit-api-forum/how-to-get-point-on-ellipse/m-p/9029436#M41332

0 Likes
Message 6 of 7

jeremytammik
Autodesk
Autodesk

Congratulations on solving the task (and on being a girl too 🙂

 

Would you like to share a snippet of code showing how you did it?

 

Thank you!

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 7 of 7

Anonymous
Not applicable
Function CreateEllipseBy2Points(doc As Document, p0 As XYZ, p1 As XYZ, el As Ellipse) As Ellipse


        Dim Angle0 As Double

        Dim Angle1 As Double


        Dim ira0 As IntersectionResultArray
        Dim l0 As Line = Line.CreateBound(el.Center, p0)
        el.Intersect(l0, ira0)

        Dim ira1 As IntersectionResultArray
        Dim l1 As Line = Line.CreateBound(el.Center, p1)
        el.Intersect(l1, ira1)

        If ira0.Size > 0 Then
            Angle0 = ira0.Item(0).UVPoint.U
        Else
            Angle0 = el.GetEndParameter(0)
        End If

        If ira1.Size > 0 Then
            Angle1 = ira1.Item(0).UVPoint.U
        Else
            Angle1 = el.GetEndParameter(1)
        End If

         Return Ellipse.CreateCurve(el.Center, el.RadiusX, el.RadiusY, el.XDirection, el.YDirection, Angle0, Angle1)


    End Function
0 Likes