Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Export As functionality

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
IPrtk
229 Views, 3 Replies

Export As functionality

I have created a plugin using C#. I want to

  1. Programmatically set the active document in the editor context.
  2. Export the document in desired format that will be passed programmatically.

Can someone point me to the class/namespace that will help me further?

3 REPLIES 3
Message 2 of 4
norman.yuan
in reply to: IPrtk

1. Not sure what do you mean by saying "set the active document in the editor context". Document class has Editor property, which is only usable when the document is active. So, if your plugin refers the active document, its Editor is available.

 

2. You may want to elaborate more about "export document". What is exactly you want to export: exporting as another file format, or certain data only... So, depending on the task in hand, you probably use many namespaces/classes in the 2 (0r 3) ACAD managed references (accoremgd/acdbmgd, and possibly acmgd), and also possibly other managed references of AutoCAD verticals (C3D, Map, Architecture...). You have to be specific about what "export document" means.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 4
IPrtk
in reply to: norman.yuan

Problem

I am trying to create a plugin that will automatically convert the files in a folder from DWG to the DXF format.

 

a)  I am able to integrate the plugin using VS2022 in the AutoCAD window. While I am debugging, the file Drawing1.DWG automatically opens up and then I can use the command "NETLOAD" and load my plugin where I am opening the documents in the editor context.

b) As the documents (all files of the folder) are opened in the editor, the Drawing1.DWG is set as the active document.

 

Message 4 of 4
_gile
in reply to: IPrtk


@IPrtk  a écrit :

I am trying to create a plugin that will automatically convert the files in a folder from DWG to the DXF format.


Have a look at the Database.DxfOut method.

 


@IPrtk  a écrit :

a)  I am able to integrate the plugin using VS2022 in the AutoCAD window. While I am debugging, the file Drawing1.DWG automatically opens up and then I can use the command "NETLOAD" and load my plugin where I am opening the documents in the editor context.

b) As the documents (all files of the folder) are opened in the editor, the Drawing1.DWG is set as the active document.


You could avoid opening each document in the editor by creating 'side databases'.

Here's a simple example:

private void SaveAsDxf(string directoryName)
{
    foreach (string fileName in Directory.GetFiles(directoryName, "*.dwg"))
    {
        using (var db = new Database(false, true))
        {
            db.ReadDwgFile(fileName, FileOpenMode.OpenForReadAndAllShare, true, null);
            db.DxfOut(Path.ChangeExtension(fileName, ".dxf"), 16, true);
        }
    }
}


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report