2
dgnを一括インポートする必要があります。私が使用してAPIの最新のコマンドオプションを使用してこの操作を行うことができます。セッション内でAutoCADコマンドを実行するContext
Application.DocumentManager.MdiActiveDocument.Editor.Command("-dgnimport", currentdgnname, "", "Master", "Standard");
しかし、問題は私も描画(および保存されたファイル名)の保存を制御する必要があるということです。私はこのようなセッションのコンテキストで私のコマンドを使用せずにこれを行う方法が表示されない:
const string DGNIMPORTBATCHname = "DGNIMPORTBATCH";
[CommandMethod(DGNIMPORTBATCHname, CommandFlags.Session)]
Editor.Command方法をただしのみ、ドキュメントのコンテキストです。
ドキュメントロックの追加は機能しません。セッションコマンド中にドキュメントコンテキストで実行中のコードに切り替える方法はありますか?
**編集:Activationcontextとサンプルコード:
Application.DocumentManager.ExecuteInApplicationContext();
Application.DocumentManager.ExecuteInCommandContextAsync();
EDIT:
はconst string DGNIMPORTBATCHname = "DGNIMPORTBATCH";
[CommandMethod(DGNIMPORTBATCHname)]
public static void RunDGNIMPORTBATCH()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
OpenFileDialog ofd = new OpenFileDialog("Convert DGNs", "", "dgn", "", OpenFileDialog.OpenFileDialogFlags.AllowMultiple);
System.Windows.Forms.DialogResult dr = ofd.ShowDialog();
if (dr != System.Windows.Forms.DialogResult.OK)
return;
foreach (string f in ofd.GetFilenames())
{
string dwgfilename = Path.Combine(Path.GetDirectoryName(f), Path.GetFileNameWithoutExtension(f) + ".dwg");
if (File.Exists(dwgfilename))
File.Delete(dwgfilename);
currentdgnname = f;
currentdwgname = dwgfilename;
List<string> names = new List<string>() { currentdgnname, currentdwgname };
//creates our document and sets it current Application.DocumentManager.ExecuteInApplicationContext(CreateDGNDocHelper, names);
currentdoc.Editor.Command("-dgnimport", currentdgnname, "", "Master", "Standard");
currentdoc.Editor.Command("._ZOOM", "Extents");
}
}
static Document currentdoc;
static void CreateDGNDocHelper(object data)
{
currentdoc = Application.DocumentManager.Add("acad.dwt");
Application.DocumentManager.MdiActiveDocument = currentdoc;
}
static string currentdgnname;
static string currentdwgname;
私はこれに従います。しかし、唯一の初期文書ではコマンドが得られます。 –
@DavidWolfe、あなたは精巧にできますか? –
サンプルコード –