.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Beginner Autocad API .NET C#

4 REPLIES 4
Reply
Message 1 of 5
Sined99
3100 Views, 4 Replies

Beginner Autocad API .NET C#

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.

4 REPLIES 4
Message 2 of 5
mzakiralam
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.

Message 3 of 5
DiningPhilosopher
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).
Message 4 of 5
Sined99
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);

        }

 

    }

}

Message 5 of 5
mzakiralam
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...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost