Author Topic: BRep: converting EllipticalArc3d to Ellipse not working in 2018 but was in 2016  (Read 3138 times)

0 Members and 1 Guest are viewing this topic.

Michael2

  • Mosquito
  • Posts: 6
Hello all.

So I'm looping through a Face's Loops, and then looping through its Edges. Everything is fine until I get an EllipticalArc for a nativecurve.
I'm basically tracing the edge to convert it to a PolyLine. I know Gile has written some classes that convert Regions to PolyLines, but this code existed prior to me finding that. And rather than rewrite my stuff to use Gile's code, I'm hoping I can just fix (what I think is) one line of code and I'll be back up and running.

As I said, this existed and worked in Acad2016, but it doesn't work in 2018.

Here's a quick snippet... I suspect the code that is wrong is the "New Ellipse" line and I'm hoping someone will point out what I'm doing wrong.

Code: [Select]
Dim F As BRep.Face = --some face--

For Each L As BRep.BoundaryLoop In F.Loops
Dim bClosed As Boolean = False
Dim bErr As Boolean = False
Dim iEdgeCount As Integer = 0
 
Do Until bClosed Or bErr

Dim E As BRep.Edge = L.Edges(iEdgeCount)
Dim C As Curve3d = E.Curve
Dim extC As ExternalCurve3d = C
Dim nativeCurve As Curve3d = extC.NativeCurve

If extC.IsEllipticalArc Then
Dim ellArc3d As EllipticalArc3d = nativeCurve
Dim VecToUse As Vector3d = ellArc3d.Normal
Dim ellActual As New Ellipse(ellArc3d.Center, VecToUse, ellArc3d.MajorAxis * ellArc3d.MajorRadius, ellArc3d.MinorRadius / ellArc3d.MajorRadius, ellArc3d.StartAngle, ellArc3d.EndAngle)

End If

iEdgeCount += 1
Loop
Next

The EllArc3d looks as I expect, meaning the StartPoint and EndPoint are where they should be: See EllArc3d.jpg.
But when I use the same "New Ellipse" command the StartPoint and EndPoint are different: See ellActual.jpg.

The full face is shown in AntiSwirlFace.jpg. I've BOLDED the elliptical curve that I'm specifically having probs with. There are other elliptical curves in that geometry and they are all doing a similar thing.



Michael2

  • Mosquito
  • Posts: 6
Got it...

Code: [Select]
Dim ellArc3d As EllipticalArc3d = nativeCurve
Dim c2 As Curve = Curve.CreateFromGeCurve(ellArc3d)
Dim ellActual As Ellipse = TryCast(c2, Ellipse)

Jeff H

  • Needs a day job
  • Posts: 6150
Glad I could help ;D , and welcome to the Swamp!

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Hi,

This is due to the EllipticalArc3d StartAngle and EnAngle properties correspond to the Ellipse StartParam and EndParam.
This is not specific to AutoCAD 2018, it was the same in prior versions.

We can compute the Ellipse StartAngle and EnAngle from its StartParam and EndParam.
Tan(Angle) / Tan(Parameter) = MinorRadius / MajorRadius

Code - C#: [Select]
  1. EllipticalArc3d ea = (EllipticalArc3d)curve.NativeCurve;
  2. double ratio = ea.MinorRadius / ea.MajorRadius;
  3. double startAngle = Math.Atan2(Math.Sin(ea.StartAngle) * ratio, Math.Cos(ea.StartAngle));
  4. double endAngle = Math.Atan2(Math.Sin(ea.EndAngle) * ratio, Math.Cos(ea.EndAngle));
  5. Ellipse el = new Ellipse(ea.Center, ea.Normal, ea.MajorAxis * ea.MajorRadius, ratio, startAngle, endAngle));

« Last Edit: March 14, 2018, 04:16:58 PM by gile »
Speaking English as a French Frog

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Glad I could help ;D , and welcome to the Swamp!

So that's you!...
I always thought ActivistInvestor was a clone of Tony T.
Speaking English as a French Frog

Michael2

  • Mosquito
  • Posts: 6
Thank you Jeff and gile!
Gile, always with the info behind the answer! Muchly appreciated!


SEANT

  • Bull Frog
  • Posts: 345
Glad I could help ;D , and welcome to the Swamp!

So that's you!...
I always thought ActivistInvestor was a clone of Tony T.

I thought the same.  A Deep Clone.
Sean Tessier
AutoCAD 2016 Mechanical

WILL HATCH

  • Bull Frog
  • Posts: 450
Glad I could help ;D , and welcome to the Swamp!

So that's you!...
I always thought ActivistInvestor was a clone of Tony T.

Ditto... like Tony had a near death experience and became a nicer guy