• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Contributor
    Posts: 14
    Registered: ‎01-27-2008

    C# Draw Arc with 3 points

    1163 Views, 16 Replies
    02-03-2008 12:56 PM
    please help me, I'm trying to find a way to draw an Arc with 3 points but i can't.

    here is parth of the code, (AddArc) method only accepts starting angle, end angle, radius, center point
    I want to enter 3 points that define the Arc

    AcadModelSpace mod;
    mod.AddArc(p1, 23.4, 0, 180);

    please Help
    Thank you
    Please use plain text.
    Distinguished Contributor
    Posts: 223
    Registered: ‎02-17-2006

    Re: C# Draw Arc with 3 points

    02-04-2008 11:16 AM in reply to: newbie1221
    Since you are using COM interop I would suggest you visit the VBA forums for help in the future.

    To answer your question, you could use the AutoCad command prompt using SendCommand() but I would advise against it (unless you absolutely have to).

    If the addarc() function only takes those 3 arguments, you will probably have no choice but to calculate what those three arguments should be, and feed them to AutoCad in the manner it expects. You could also create a dummy arc and modify its properties, but again you would need to calculate those said properties on your own (radius, angles, etc...).

    ie: Calculate your start/end angles, ctr pt, and radius and use those to define your arc in the format that AutoCad expects. If you do not want to handle the math, you will have to send text to the AutoCad command line through a script.
    Please use plain text.
    *Laurie Comerford

    Re: C# Draw Arc with 3 points

    02-04-2008 12:17 PM in reply to: newbie1221
    Hi Jason,

    What is the point of a poster using .NET with the COM interop trying to get
    help in the VBA newsgroup? Users there will see C# and refer them back
    here. This is the NG for programming using .NET and should be so regardless
    of the methods used within .NET


    --


    Regards

    Laurie Comerford


    wrote in message news:5838476@discussion.autodesk.com...
    Since you are using COM interop I would suggest you visit the VBA forums for
    help in the future.

    To answer your question, you could use the AutoCad command prompt using
    SendCommand() but I would advise against it (unless you absolutely have to).

    If the addarc() function only takes those 3 arguments, you will probably
    have no choice but to calculate what those three arguments should be, and
    feed them to AutoCad in the manner it expects. You could also create a dummy
    arc and modify its properties, but again you would need to calculate those
    said properties on your own (radius, angles, etc...).

    ie: Calculate your start/end angles, ctr pt, and radius and use those to
    define your arc in the format that AutoCad expects. If you do not want to
    handle the math, you will have to send text to the AutoCad command line
    through a script.
    Please use plain text.
    Distinguished Contributor
    Posts: 223
    Registered: ‎02-17-2006

    Re: C# Draw Arc with 3 points

    02-04-2008 12:51 PM in reply to: newbie1221
    I didn't notice right away that his sample code was in C#.

    However, on that subject, the other forum has much more info about the COM API that directly applies to questions like these. Most of the knowledge here seems to be biased towards the ObjectArx .NET libraries instead. Therefore the VBA forums is still a better place to look when interacting with the COM library, even when you need to translate any solutions you find into C#.

    My comment was not meant to be a "stay out of this forum" post. It was more of a "here is better place to search for a solution".

    ps: You like jumping on people, don't you?
    Please use plain text.
    Distinguished Contributor
    Posts: 1,691
    Registered: ‎12-15-2003

    Re: C# Draw Arc with 3 points

    02-04-2008 01:22 PM in reply to: newbie1221
    It's all about the API. All users in the VBA group use the ActiveX API. This includes VB6 and Delphi (have you ever told them to get lost) users. The users in this group predominantly use the .NET API. Therefore the OP might be more likely to get help in the VBA group if the users can see past the language he is using.

    In this group there are both VB.NET & C# users using the .NET API . The fact they are using different languages has not stopped them help each other on the real purpose of this group the .NET API.
    Please use plain text.
    Contributor
    Posts: 14
    Registered: ‎01-27-2008

    Re: C# Draw Arc with 3 points

    02-04-2008 01:53 PM in reply to: newbie1221
    Thank you so much, Jason
    I'm a Programmer and I'm just starting to learn more about Programming for AutoCAD.

    Is there a better way to Program for AutoCAD rather than using COM interop, I saw some Database work like Commit() ,and Stuff? I tried looking at samples it all make sense but I always get FILENOTFOUND Execption just if I used anything in these NameSpaces:
    Autodesk.AutoCAD.Geometry
    Autodesk.AutoCAD.DatabaseServices
    Although I added the 2references:
    acdbmgd.dll
    acmgd.dll

    Any Tips?


    Thanx again for your Help :smileyhappy: Message was edited by: Newbie1221
    Please use plain text.
    Distinguished Contributor
    Posts: 1,691
    Registered: ‎12-15-2003

    Re: C# Draw Arc with 3 points

    02-04-2008 02:01 PM in reply to: newbie1221
    2005 had a very limited .NET API. If you have 2006 onwards checkout http://through-the-interface.typepad.com/through_the_interface/2007/11/devtv-introduct.html
    Please use plain text.
    Distinguished Contributor
    Posts: 223
    Registered: ‎02-17-2006

    Re: C# Draw Arc with 3 points

    02-04-2008 02:49 PM in reply to: newbie1221
    http://usa.autodesk.com/adsk/servlet/index?id=1911627&siteID=123112

    There should be links to documentation directly related to programming with the .NET arx API. Also look at the C++ documentation for ObjectArx, as I think there were some .NET samples hidden in the package you can download.

    Also, Nathan is right about the "Through the interface" blogs. They have some great info.

    As a last resort, you can search these forums.. The posts about how to set up a project that uses the arx.NET API are old, but they should still be here (they are what I used to get started).

    Good luck.
    Please use plain text.
    Contributor
    Posts: 14
    Registered: ‎01-27-2008

    Re: C# Draw Arc with 3 points

    02-04-2008 03:52 PM in reply to: newbie1221
    Thank you all for the tips, Indeed those were very helpful :smileyhappy:)
    Please use plain text.
    *Tony Tanzillo

    Re: C# Draw Arc with 3 points

    02-04-2008 05:15 PM in reply to: newbie1221
    If you want to use the managed API (which means that you are building a NETLOAD-able DLL, not an .EXE), this is probably the easiest way to do what you need, without having to do the geometry calculations:

    Using Autodesk.AutoCAD.Geometry;

    Point3d startPoint = //... start point of the arc
    Point3d pointOnArc = //... any point on the arc segment
    Point3d endPoint = //... end point of the arc

    CircularArc3d arc = new CircularArc3d( startPoint, pointOnArc, endPoint );

    From there, you can query the properties of the CircularArc3d for its center, radius, and start/end angles, and use them to create an Arc entity.

    If you've never used the managed ObjectARX API before, then be forewarned that it is not easy to learn (it can take years to learn it to the extent needed to develop real applications).

    You can ease your way into the managed API gradually by using it in conjunction with ActiveX (your problem is a good example of that, because you can create the ARC through ActiveX, but use the managed API to do the needed calculations).

    And contrary to what Laurie says, we generally don't link programming languages to APIs here. This newsgroup focuses mainly on using the managed ObjectARX API without regard for langauge. For ActiveX, your best bet is the VBA newsgroup because syntax differences aside, the API is the same regardless of what langauge you use.

    --
    http://www.caddzone.com

    AcadXTabs: MDI Document Tabs for AutoCAD 2008
    Supporting AutoCAD 2000 through 2008
    http://www.acadxtabs.com

    wrote in message news:5838744@discussion.autodesk.com...
    Thank you all for the tips, Indeed those were very helpful :smileyhappy:)
    Please use plain text.