.NET

Reply
Active Contributor
WWFreeman
Posts: 27
Registered: ‎09-02-2012
Message 1 of 6 (663 Views)
Accepted Solution

Arc and CircularArc2d

663 Views, 5 Replies
02-26-2013 09:13 PM

Hello everyone.

 

I'm a bit riddled by how conversion between the two types should work and whether it is what should be done. As I trace boundary of a 2d figure ( editor.TraceBoundary( ... ) ) I get a collection with - say - one Polyline object.

 

When I want to extract an arc segment from the polyline, I am using (polyline.GetArcSegment2dAt( ... )). The object I get is of type CircularArc2d.

 

If I save this object somewhere and pull it back later, how can I have it drawn? So far I tried to convert CircularArc2d to Arc:

 

CircularArc2d carc = ...
Arc aarc = new Arc(
  Convertor.ToPoint3d(carc.Center),
  carc.Radius,
  carc.StartAngle,
  carc.EndAngle
);

But that didn't turn out well. The circular arc seems to determine its start by the start point, having start angle = 0, while the arc understands this zero as "start from polar zero radians, as seen from the center". I tried to set a start point to the arc:

Arc aarc = new Arc();
aarc.StartPoint = Convertor.ToPoint3d(carc.StartPoint);
aarc.EndPoint = Convertor.ToPoint3d(carc.EndPoint);
aarc.Center = Convertor.ToPoint3d(carc.Center);

But that produces exception saying that setting start point isn't implemented for the Arc type.

 

I can go for calculating the start/end angle for Arc, but something tells me there must be a more elegant and more precise way to trace arcs, save them externally and use them later. I could use a hand with this one.

 

Thanks!


WWFreeman wrote:

 

In the meantime, can you confirm there is no way we can actually extract Arc instead of CircularArc2d/3d from a Polyline?


Polyline.Explode produce Arcs and Lines.

 

Distinguished Mentor
gasty1001
Posts: 582
Registered: ‎04-11-2010
Message 2 of 6 (647 Views)

Re: Arc and CircularArc2d

02-26-2013 10:07 PM in reply to: WWFreeman

Hi,

 

It seems there is not an elegant solution, check this link: http://forums.autodesk.com/t5/NET/Create-Arc-with-StartPoint-EndPoint-Radius/m-p/3773066#M33369. Almost 50 lines of code to create an arc!

Another solution could be using editor.runcommand as implemented by TT in this link :RunCommand .

 

Gaston Nunez

 

 

Active Contributor
WWFreeman
Posts: 27
Registered: ‎09-02-2012
Message 3 of 6 (642 Views)

Re: Arc and CircularArc2d

02-26-2013 10:14 PM in reply to: gasty1001

Gosh, yeah, that doesn't look neat. :smileyvery-happy:

 

Alright, I'll be having some 'fun' with this topic and then come back and mark this as solved if nobody else opposes.

 

In the meantime, can you confirm there is no way we can actually extract Arc instead of CircularArc2d/3d from a Polyline?

Moderator
Alexander.Rivilis
Posts: 1,450
Registered: ‎04-09-2008
Message 4 of 6 (638 Views)

Re: Arc and CircularArc2d

02-26-2013 10:32 PM in reply to: WWFreeman

WWFreeman wrote:

 

In the meantime, can you confirm there is no way we can actually extract Arc instead of CircularArc2d/3d from a Polyline?


Polyline.Explode produce Arcs and Lines.

 


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Active Contributor
WWFreeman
Posts: 27
Registered: ‎09-02-2012
Message 5 of 6 (629 Views)

Re: Arc and CircularArc2d

02-26-2013 10:53 PM in reply to: Alexander.Rivilis

Right. In my case it was wrong to start using CircularArc2d type.

 

However, gasty's post has revealed me further very useful stuff. Thank you!

 

If I happen to write a CircularArc2d -> Arc converter, it will probably be posted here as I saw none.

Moderator
Alexander.Rivilis
Posts: 1,450
Registered: ‎04-09-2008
Message 6 of 6 (625 Views)

Re: Arc and CircularArc2d

02-26-2013 10:58 PM in reply to: WWFreeman

WWFreeman wrote:
If I happen to write a CircularArc2d -> Arc converter, it will probably be posted here as I saw none.

You can cut CircularArc2d -> Arc converter from this post.


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.