Teigha File Converter を使って、DWG/DXF 変換 2016/ 9/ 3 (2016/ 9/ 6 更新)
■Teigha File Converter の入手先
Open Design Alliance
https://www.opendesign.com/guestfiles/TeighaFileConverter
■Teigha File Converter の起動オプション(コマンドラインフォーマット)
下図、ダイアログは、TeighaFileConverter.exe を、" /?" オプションで起動すると出てきます。
・Recurse Input Folder : サブフォルダ以内のファイルを含めるかどうか
・Audit each file :監査を行うかどうか
※Input、Output のファイルタイプが同じ場合は、Input、Output 同じフォルダ名は指定できません。
※ファイルフィルターに、ワイルドカードを使わずにファイル名をそのまま指定すると、そのファイルだけが変換対象になります。

■Teigha File Converter をプログラムから起動する
ShellExecute、ShellExecuteEx を SW_HIDE で使うと非表示で実行できます。

■ソースコード
unit TeighaFCUnit;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
ExtCtrls, ShellApi;
type
TForm3 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Edit8: TEdit;
Label8: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private 宣言 }
public
{ Public 宣言 }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
// 起動する
procedure TForm3.Button1Click(Sender: TObject);
var
ExeFile : String;
Params : String;
hInstance : Cardinal;
begin
ExeFile := Edit1.Text;
Params := Edit2.Text + ' ' + Edit3.Text + ' ' + Edit4.Text + ' ' +
Edit5.Text + ' ' + Edit6.Text + ' ' + Edit7.Text + ' ' + Edit8.Text;
hInstance := ShellExecute(Handle, 'open', PChar(ExeFile), PChar(Params), nil,
SW_SHOWNORMAL); // SW_HIDE or SW_SHOW
if hInstance <= 32 then begin
MessageBox(Handle, '起動に失敗しました.', 'エラー', MB_ICONSTOP);
end;
end;
// 起動して終了を待つ
procedure TForm3.Button2Click(Sender: TObject);
var
SEInfo: TShellExecuteInfo;
ExitCode : DWORD;
ExeFile, Params : string;
begin
ExeFile := Edit1.Text;
Params := Edit2.Text + ' ' + Edit3.Text + ' ' + Edit4.Text + ' ' +
Edit5.Text + ' ' + Edit6.Text + ' ' + Edit7.Text + ' ' + Edit8.Text;
FillChar(SEInfo, SIzeOf(SEInfo), 0);
with SEInfo do begin
cbSize := SizeOf(TShellExecuteInfo);
fMask := SEE_MASK_NOCLOSEPROCESS;
Wnd := Handle;
lpFile := PChar(ExeFile);
lpParameters := PChar(Params);
// 表示・非表示
nShow := SW_SHOWNORMAL; // or SW_HIDE
end;
if ShellExecuteEx(@SEInfo) then begin
Caption := '変換中...';
repeat
Application.ProcessMessages;
GetExitCodeProcess(SEInfo.hProcess, ExitCode);
until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
MessageBox(Handle, '終了しました.', '情報', MB_ICONINFORMATION);
end
else begin
MessageBox(Handle, '起動に失敗しました.', 'エラー', MB_ICONSTOP);
end;
Caption := '';
end;
end.