I have created a plugin using C#. I want to
Can someone point me to the class/namespace that will help me further?
Solved! Go to Solution.
Solved by _gile. Go to Solution.
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
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.
@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);
}
}
}
Can't find what you're looking for? Ask the community or share your knowledge.