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

    .NET

    Reply
    Contributor
    Leimhu
    Posts: 11
    Registered: ‎02-05-2012

    How to open autocad.exe in C# , PLEASE HELP!

    1120 Views, 23 Replies
    02-05-2012 12:13 AM

    I am using Visual.net 2008 with autocad.net API, autocad2010, windows 7 home

    right now, i want to start autocad.exe, and draw some lines in it, by using C# WindowsFormsApplication, not  C# Class Library

    still i cannot start autocad.exe

     

    I hope to open cad by autocad.net API, not ObjectARX or others

    I am a new one,  please HELP ME

    thanks very very much !

    Please use plain text.
    Valued Contributor
    Posts: 61
    Registered: ‎04-14-2010

    Re: How to open autocad.exe in C# , PLEASE HELP!

    02-05-2012 02:12 AM in reply to: Leimhu

    There is no exe autocad, you mean acad.exe?

     

    You cant program in autocad through windows forms with just opening acad.exe with out ObjectARX

    Please use plain text.
    *Expert Elite*
    Hallex
    Posts: 1,371
    Registered: ‎10-08-2008

    Re: How to open autocad.exe in C# , PLEASE HELP!

    02-05-2012 03:14 AM in reply to: Leimhu

    If you want to don't add any reference to acad's libraries

    in this case just one way to do it is using late-binding to AutoCAD

    There is a ton of code to do this work

    _____________________________________
    C6309D9E0751D165D0934D0621DFF27919
    Please use plain text.
    *Expert Elite*
    Hallex
    Posts: 1,371
    Registered: ‎10-08-2008

    Re: How to open autocad.exe in C# , PLEASE HELP!

    02-05-2012 05:43 AM in reply to: Leimhu

    Here are 2 files were written on vb.net

    See if this will be working fror you

    _____________________________________
    C6309D9E0751D165D0934D0621DFF27919
    Please use plain text.
    Contributor
    Leimhu
    Posts: 11
    Registered: ‎02-05-2012

    Re: How to open autocad.exe in C# , PLEASE HELP!

    02-06-2012 01:54 AM in reply to: Hallex

    Thanks very much ! really appreciate your great help ~

    actually i work it out by using C# library

    Please use plain text.
    *Expert Elite*
    Hallex
    Posts: 1,371
    Registered: ‎10-08-2008

    Re: How to open autocad.exe in C# , PLEASE HELP!

    02-06-2012 08:17 AM in reply to: Leimhu

    Create Wndws Forms Application project

    Name it AcadTestExe

    Add form Form1 to project

    Drop on form OpenFileDialog, texbox and button

    Keep default names for all controls

    Add class ReflectionCommands.cs

    Copy all codes accodingy to classes, then hit F5

     

    ~'J'~

    _____________________________________
    C6309D9E0751D165D0934D0621DFF27919
    Please use plain text.
    Contributor
    Leimhu
    Posts: 11
    Registered: ‎02-05-2012

    Re: How to open autocad.exe in C# , PLEASE HELP!

    02-06-2012 06:26 PM in reply to: Hallex

    Dear Hallex, you are genius!!!

    I tried your codes, and it works very well~

    Thank for your help, It's really great~

    althought I cannot figured out how you fix it without adding any CAD liraries or dll

    I am a new one in cad developping , these days I kept searching for any useful book or documents

    still there is no result

    Can you give me some advice for learning cad with C# ? Is there any useful documents for me ?

    PS: I can draw circle by your  incredible codes, Could you please tell me how to draw a ARC ?

    Please use plain text.
    *Expert Elite*
    Hallex
    Posts: 1,371
    Registered: ‎10-08-2008

    Re: How to open autocad.exe in C# , PLEASE HELP!

    02-06-2012 09:00 PM in reply to: Leimhu

    C'mon

    This is very simple code

    Glad you like it

    This project does not require any

    CAD library

    I tested it on A2009-2010 Win7

     

    Will be back

     

    ~'J'~

    _____________________________________
    C6309D9E0751D165D0934D0621DFF27919
    Please use plain text.
    Contributor
    Leimhu
    Posts: 11
    Registered: ‎02-05-2012

    Re: How to open autocad.exe in C# , PLEASE HELP!

    02-06-2012 11:07 PM in reply to: Hallex

    your code is incredible simple, I enjoy it

    I cannot understand you until now

    with your help, I figured it how to draw an arc

    thanks ~~~~~~

    and please give me some advice :smileytongue:

    Please use plain text.
    Contributor
    Leimhu
    Posts: 11
    Registered: ‎02-05-2012

    Re: How to open autocad.exe in C# , PLEASE HELP!

    02-07-2012 12:27 AM in reply to: Hallex

    dear Hallex:

       I use your code to draw some lines in cad,

      It is ok in WIN7 64bit + AUTOCAD2008 and WinXP + AUTOCAD2004

     but errors happened in WinXP + AUTOCAD2008

     my code is :

     

    for (int k = 1; k < iHH.OutHHXY.Row - 1; k++)   
    {
    pt2[0] = iHH.OutHHXY[k, 0];
    pt2[1] = iHH.OutHHXY[k, 1];
    drawLineInObject(oSpace, pt1[0], pt1[1], pt2[0], pt2[1], "0");
    pt1[0] = pt2[0];
    pt1[1] = pt2[1];
    }

     

    The error happened in these lines:

    object oLine = oBlock.GetType().InvokeMember("AddLine", BindingFlags.InvokeMethod, null, oBlock, pts);
    oLine.GetType().InvokeMember("Layer", BindingFlags.SetProperty, null, oLine, new object[] { layer });
    oLine.GetType().InvokeMember("Update", BindingFlags.InvokeMethod, null, oLine, null);

     

    BUT , if I debug the loops one by one, It runs well. I am so confused~

    please help me ~~

    Thanks very much !!!

     

     

     

     

    1

     

     

     

    Please use plain text.