Design Automation API for AutoCAD:.pc3 ファイルの上書き

A split-screen image showing a computer setup with a monitor and keyboard on the left, and a directory listing of AutoCAD plot settings files on the right, with an arrow indicating a connection to cloud settings.

Design Automation API for AutoCAD で PDF ファイルや DWF ファイルを生成する際、ローカル コンピュータの環境で日頃利用しているプロッタ環境設定ファイル(.pc3 ファイル)をそのまま使用したい場合があります。

プロッタを追加ウィザード を利用して作成した独自の pc3 ファイルも、AutoCAD の既定の pc3 ファイルを編集した場合も、Design Automation API for AutoCAD で活用することが出来ます。いずれの場合も、pc3 ファイルを AppBundle に同梱しておき、WorkItem の実行時に、コアエンジンが参照出来るようにする必要があります。

AppBundle から展開されるパスは、アドイン ファイル内の処理で取得することが出来ます。また、同じパスに pc3 ファイルが配置されていると考えることが可能です。アドイン ファイルの配置パスは、過去にご紹介した Design Automation API for AutoCAD:AppBundle 内のコンテンツ利用 の記事でご紹介しています。

印刷処理の場合、Design Automation API for AutoCAD のコアエンジンも、ローカル コンピュータのデスクトップ版 AutoCAD 同様、WorkItem 実行時に用意された仮想マシンの作業フォルダに、既定の pc3 ファイルを展開して印刷処理に備えます。

Design Automation API:adskDebug オプション の方法で、作業環境上の相対パスを把握することが可能です。

フォルダー内のいくつかの PC3 プロッタ設定ファイルとフォルダーが表示されているスクリーンショット。

AppBundle に同梱した pc3 ファイルは、次のようにパスを解決、コア エンジンが参照するパスにコピーすることで、印刷処理時に流用出来るようになります。

    …
        string strCfgPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
        strCfgPath = strCfgPath.Substring(0, strCfgPath.IndexOf(System.IO.Path.GetFileName(strCfgPath)));
        string strDestPath = strDwgPath;
        strDestPath += “userdata\\Roaming\\Plotters\\” + “DWG To PDF.pc3”;
        strCfgPath += “DWG To PDF.pc3”;
        log(“\n>>>>> DWG To PDF.pc3 path = {0}”, strCfgPath);
        log(“\n>>>>>> Destination path = {0}”, strDestPath);
        if (System.IO.File.Exists(strCfgPath))
        {
         log(“\n>>>>>> DWG To PDF.pc3 Found”);
         try
         {
          System.IO.File.Copy(strCfgPath, strDestPath, true);
          log(“\n>>>>>> DWG To PDF.pc3 was copied to destination path = {0}”, strDestPath);
         }
         catch (System.Exception ex)
         {
          log(“\n>>>>>> System.IO.File.Copy failed : {0}”, ex.Message);
         }
        }
        else
        {
         log(“\n>>>>>> DWG To PDF.pc3 is *NOT* Found”);
        }
    …
     
      private static void log(string format, params object[] args) { Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(format, args); }
     
    …

By Toshiaki Isezaki

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading