У меня проблема с сохранением файла чертежа.
Autocad 2024
При разработке Autocad у меня возникла проблема проблема с сохранением активного файла чертежа.
Я пытаюсь использовать следующий код для сохранения файла.
Но я выдаю ошибку исключения, например:
"Autodesk.AutoCAD.Runtime.Exception: ' eFileAccessErr'" Или "внутренняя ошибка: !dbobji!.cpp@8668: eNotOpenForWrite"
`
// (C) Copyright 2024,
//
с использованием Autodesk.AutoCAD.ApplicationServices;
с использованием Autodesk.AutoCAD.DatabaseServices;
с использованием Autodesk.AutoCAD.EditorInput;
с использованием Autodesk.AutoCAD.Geometry;
с использованием Autodesk.AutoCAD.Runtime ;
с использованием системы;
Код: Выделить всё
// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(Strore_lab01.MyCommands))]
namespace Strore_lab01
{
// This class is instantiated by AutoCAD for each document when
// a command is called by the user the first time in the context
// of a given document. In other words, non static data in this class
// is implicitly per-document!
public class MyCommands
{
[CommandMethod("SaveActiveDrawing")]
public static void SaveActiveDrawing()
{
Document acDoc = Application.DocumentManager.MdiActiveDocument;
string strDWGName = acDoc.Name;
object obj = Application.GetSystemVariable("DWGTITLED");
// Check to see if the drawing has been named
if (System.Convert.ToInt16(obj) == 0)
{
// If the drawing is using a default name (Drawing1, Drawing2, etc)
// then provide a new name
strDWGName = "c:\\MyDrawing.dwg";
}
// Save the active drawing
acDoc.Database.SaveAs(strDWGName, true, DwgVersion.Current, acDoc.Database.SecurityParameters);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/789 ... in-autocad