.NET

Reply
Contributor
Sined99
Posts: 15
Registered: ‎04-26-2013
Message 1 of 5 (1,557 Views)

Beginner Autocad API .NET C#

1557 Views, 4 Replies
04-29-2013 01:10 AM

Hello,

I am a begginer using the .net API for autocad, I have some questions:

 

1) Can I override the "SaveAs..." dialog? I Will show a winform instead of the SaveFileDialog.

 

2) I know I must create a .dll(with the winform) and a XML file and copy it in the autocad fold, so autocad loads automatically the .dll, right?

 

 

I am using visual studio 2010 and autocad 2013.

 

Thank you very much.

Mentor
mzakiralam
Posts: 231
Registered: ‎11-09-2012
Message 2 of 5 (1,538 Views)

Re: Beginner Autocad API .NET C#

04-29-2013 07:05 AM in reply to: Sined99

Hi ,

 

Your question is not so clear to me.

 

However, for first point-  you can show a winform, it is not a problem. Use the command, "Application.showmodaldialog(form_name)".

 

For 2nd point , what do you mean by xml copy? I did not get. Your DLL will not be automatically loaded in autocad. There are some steps to do that. You can load your DLL manually by using 'Netload' command. for details you can follow :NET developers guide.

 

http://exchange.autodesk.com/autocad/enu/online-help/browse#WS73099cc142f48755f2fc9df120970276f7-535...

 

 you can follow the exercise about that basics of AutoCAD .NET API.

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 3 of 5 (1,515 Views)

Re: Beginner Autocad API .NET C#

04-29-2013 11:56 AM in reply to: Sined99
No, there's no way to override the SaveAs dialog. The dialog can also appear in other commands (e.g., QUIT) as well. You should probably write your own replacement for the SAVEAS command and require it to be used instead (replacing the SAVEAS command with your own will not solve the problem of the dialog being used from other command like QUIT).
Contributor
Sined99
Posts: 15
Registered: ‎04-26-2013
Message 4 of 5 (1,486 Views)

Re: Beginner Autocad API .NET C#

04-29-2013 11:55 PM in reply to: Sined99

Hello,

 

Thanks for the answears.

 

When I say I must copy the XML file is because I saw a video where you must put the .DLL in a specific folder of autodesk with a XML file(like a manifest file or something like that). I attach a image of the XML file, but thanks for answear.

 

Well I have a code that by the moment I couldn't check with autocad, is correct the structure?, I have only one form called Guardar. When you insert in Autocad the command "SaveAsEsquema" it creates this form where you can change the name of the file and save it... or this is the idea.

 

 

using Autodesk.AutoCAD.Windows;

using Autodesk.AutoCAD.Runtime;

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.EditorInput;

using Autodesk.AutoCAD.DatabaseServices;

 

namespace AUTOCADDLL

{

   

public partial class Guardar : Form

    {

       

public Guardar()

        {

            InitializeComponent();

        }

       

Guardar guardar;

 

 [CommandMethod("SaveAsEsquema")]

       

public void SaveActiveDrawing()

        {

            guardar =new Guardar();

            Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(guardar);

        }

       

private void bt_Click(object sender, EventArgs e)

        {

           

Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

           

string strDWGName =@"C:\"+ textBox1.Text+".dwg";

            acDoc.Database.SaveAs(strDWGName, acDoc.Database.SecurityParameters);

        }

 

    }

}

Mentor
mzakiralam
Posts: 231
Registered: ‎11-09-2012
Message 5 of 5 (1,476 Views)

Re: Beginner Autocad API .NET C#

04-30-2013 04:51 AM in reply to: Sined99

your code looks okay. Just run it.

 

Regarding the xml file, it looks like the autoloader definition is kept there and AutoCAd will read that during start up and load your DLL. if you understand what is written in that xml file, then use it. otherwise you won't be able to rectify any problem later if there is some don't match with your dll. This is why , I recommended you to use manual load first. as you are beginner in .NET API. later you can use demand loader. you can also autoload your dll in dfferent ways. you can see the following link where demand loading is described well.

 

http://exchange.autodesk.com/autocad/enu/online-help/browse#WS73099cc142f48755-5c83e7b1120018de8c0-1...

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.