end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

Creo Element Direct DXF/DWG translatorによるME10 ver.9図面→DXF形式へのCAD変換

前回のエントリの続きです。

Creo Element Direct DXF/DWG translatorとは?

Creo Element Direct Draftingには、CADデータの変換を行うCLI(Command Line Interface)アプリ「Creo Elements/Direct DXF/DWG Translator 18.0 」(以下、translator)が付属しています。

このtranslatorは、 Draftingと共に c:\Program Files\PTC\Creo Elements\Direct Drafting 18.0\dxfdwg にinstallされ、このpathには次のfileが含まれています。

DXFDWG.con 設定ファイル ※
cclogo.gif readmeに表示されるロゴ
dxfdwg.exe translator本体. 以前はdxf.exeというファイル名だったらしい
readme.htm README

translatorは対話モードによる実行も可能で、dxfdwg.exe を引数なしで実行すると、対話形式で起動できます。

dxfdwg.exe の対話モード
c:\Program Files\PTC\Creo Elements\Direct Drafting 18.0\dxfdwg>dxfdwg.exe
Release: 18.0
Date Code: M020 (build 879.32, 30-Nov-2011)

Copyright (c) 2011 Parametric Technology GmbH
(a subsidiary of Parametric Technology Corporation), All Rights Reserved.
Teigha (c) 2010 by Open Design alliance. All rights reserved.
* DXF and DWG are trademark of Autodesk, Inc.
   0 : Exit program
   1 : Translate DXF to MI
   2 : Batch Translate DXF to MI
   3 : Translate MI to DXF
   4 : Batch Translate MI to DXF
   5 : Translate DWG to MI
   6 : Batch Translate DWG to MI
   7 : Translate MI to DWG
   8 : Batch Translate MI to DWG
   9 : Translate MI to SVG
  10 : Batch Translate MI to SVG
Enter the selection:
dxfdwg.exe の非対話モード

一方の非対話モードのオプションは「-?」で表示されるヘルプを参照するか、付属のドキュメント(readme.htm)をご覧下さい。

c:\Program Files\PTC\Creo Elements\Direct Drafting 18.0\dxfdwg>dxfdwg.exe -?
Usage:
 dxfdwg [-option] [-t] [-k] [-b batch_file] [-e config_file]
           [-f source [dest [log]]]
options:
  -i   DXF  to  MI
  -o   MI   to  DXF
  -d   DWG  to  MI
  -m   MI   to  DWG
  -s   MI   to  SVG
  -v   version
  -n   name of translator
  -?   help
Note: -b and -f are mutually exclusive.
      -t target version (only valid with options o and m)
      -k keep dest file if exists (only valid with options o and m and s)

Translatorのreadme.htm

Translatorにはreadme.htmが付属しますが、ME10 ver.9(日本語含む SJIS)->DXF関連の情報を以下に抜粋しておきます。

MI -> DXF/DWG

DXF/DWG translator reads Unicode (UTF-8, UTF-16), Roman8 or SJIS string encodings.
However there is an inconsistency between standalone DXFDWG translator read and read through Creo Elements/Direct Drafting.
When standalone DXFDWG translator reads MI files encoded in Roman8 and/or SJIS the result of translation is not the same as when DXFDWG translator is called through Creo Elements/Direct Drafting (to read the same file).
Reason why is that Creo Elements/Direct Drafting has already done, by loading such file, string re-encoding to Unicode.

と、dxfdwg.exe がas is な状態と思わせる記載があります。

KanjiTranslate in DXFDWG.con

This switch controls the translation of the Kanji characters. It can be ON or OFF (default).

って、説明になっていませんがONにしとくかな

EnableLegacyEncoding in DXFDWG.con

This switch enables old manner for storing DXF files (MI to DXF translation). It can be ON or OFF (default).

EnableLegacyEncoding OFF DXF/DWG translator uses Unicode (UTF-8) string encoding when writes DXF files.
EnableLegacyEncoding ON enables writing to Roman8 string encoding.
EnableLegacyEncoding ON in combination with KanjiTranslate ON enables writing to SJIS string encoding.

KanjiTranslate=ONの場合、EnableLegacyEncoding=ONがよさそうです。

日本語変換はKanjiTranslate=ON & EnableLegacyEncoding=ON で

readme.htmの記載内容をよく理解できなかったので、以下で、KanjiTranslateやEnableLegacyEncodingと「○○○建設工業㈱ テスト」の変換結果を記載しておきます。

0)オリジナルの文字列
○○○建設工業㈱ テスト
1)Direct Drafting による変換結果(参考)
\U+25cb\U+25cb\U+25cb\U+5efa\U+8a2d\U+5de5\U+696d\U+3231\U+3000\U+ff83\U+ff7d\U+ff84

前回のエントリに記載した通り、sjis->utf8文字参照コードになります。

2)dxfdwg.exe (KanjiTranslate=OFF EnableLegacyEncoding=OFF)
\201\U+03B3\201\U+03B3\201\U+03B3\214\337\220\357\215H\213\3\207\212\201@\373\247\341

よく分かりません。

3)dxfdwg.exe (KanjiTranslate=ON EnableLegacyEncoding=OFF)
\U+0081\U+203A\U+0081\U+203A\U+0081\U+203A\U+0152\U+0161\U+0090\U+00DD\U+008DH\U+2039\U+00C6‡\U+0160\U+0081@\U+00C3\U+00BD\U+00C4

また、よく分かりません。

4)dxfdwg.exe (KanjiTranslate=OFF EnableLegacyEncoding=ON)
\201\233\201\233\201\233\214\337\220\357\215H\213\363\207\212\201@\373\247\201E

またx2、よく分かりません。

5)dxfdwg.exe (KanjiTranslate=ON EnableLegacyEncoding=ON)
○○○建設工業㈱ テスト

機種依存文字も文字化けすることなくSJISのDXFファイルが生成されました。
(つまり、 KanjiTranslate=ON EnableLegacyEncoding=ON が良さそうです)

※Draftingの画面でDXF形式で保存した結果とエンコーディングの形式が異なりましたが、閲覧できたので、気にしないことにします。

その他参考

その他参考として、dxfdwg.exe の実行時の画面と、出力されたログファイルの内容を記載しておきます。

実行結果

> dxfdwg.exe -o -e .\DXFDWG.con -f ..\ME10_TEST\AZQ101-02-000.cad.mi
Reading file '..\ME10_TEST\ME10_ORG.cad.mi' ...

..\ME10_TEST\ME10_ORG.cad.mi
Current State:
0 .. 10 .. 20 .. 30 .. 40 .. 50 .. 60 .. 70 .. 80 .. 90 .. 100   Completed !
---------------------------------------------------------------------

ログファイル (ME10_ORG.cad.log)
※設定ファイル(DXFDWG.con)の内容をcatしているだけのように見えます。

MI to DXF translation log file
Creo Elements/Direct DXF/DWG Translator Release 18.0  (build 879.32)
dxfdwg
-------------------------------------------------------
SourceDirPath	./
DestinDirPath	./
KanjiTranslate	ON
EnableLegacyEncoding	ON
RecordByLayerInfo	OFF
CustomUnits	ON
Units	mm
UnitsScale	1
ConvertMIDimensionsToGeometry	OFF
ExplodeDXFDimensions	OFF
KeepAttributesWithPart	OFF
StartSection	DXF to MI Translator
InternalHandseed	
PolymarkerType	2
OutputACADVersion	AC1015
DXFDecimalPrecision	14
ReadAllLayoutData	OFF
TranslatePaperspace	OFF
LayoutName	
TranslateDXFPenLineSize	4
TranslateInvisibleLayers	ON
TranslateDXFInvisibleEntities	OFF
TranslateMIInvisibleEntities	OFF
TranslateSubfixDimProp	ON
TranslateSuperfixDimProp	ON
ContourSnapGap	1e-012
HatchCloseContours	ON
KeepTopScale	OFF
TranslateMIPenLineSize	1
HighSplinePrecision	OFF
HatchToContours	OFF
CreateSplineFitPoints	ON
SplineControlPointTranslation	OFF
SVGDarkBackground	ON
MinimumHatchSpacingDensity	0
FontFilesPath	./
FontMapACADtoMI	"ARIAL.TTF"	"arial"	"hp_kanj2_c"	1.2	1.666
FontMapACADtoMI	"ARIALBD.TTF"	"arial"	"osd_default"	1.2	1.666
FontMapACADtoMI	"ARIALUNI.TTF"	"arial_unicode_ms"	"arial_unicode_ms"	1.2	1.666
FontMapACADtoMI	"complex.shx"	"hp_block_v"	"hp_kanj2_c"	0.95	1.666
FontMapACADtoMI	"COUR.TTF"	"courier_new"	"hp_kanj2_c"	0.75	1.666
FontMapACADtoMI	"italic.shx"	"hp_jasc_v"	"hp_kanj2_c"	1.15	1.666
FontMapACADtoMI	"simplex.shx"	"osd_default3"	"osd_default3"	0.95	1.666
FontMapACADtoMI	"tahoma.ttf"	"tahoma"	"hp_kanj2_c"	1.25	1.666
FontMapACADtoMI	"TIMES.TTF"	"times_new_roman"	"hp_kanj2_c"	1.03	1.666
FontMapACADtoMI	"txt.shx"	"osd_default"	"osd_default"	0.9	1.666
FontMapMItoACAD	"arial"	"ARIAL.TTF"	1.2	""	0
FontMapMItoACAD	"arial_unicode_ms"	"ARIALUNI.TTF"	1.2	""	0
FontMapMItoACAD	"courier_new"	"COUR.TTF"	0.75	""	0
FontMapMItoACAD	"hp_block_c"	"complex.shx"	1.39	""	0
FontMapMItoACAD	"hp_block_v"	"complex.shx"	0.95	""	0
FontMapMItoACAD	"hp_d17_c"	"simplex.shx"	1.24	""	0
FontMapMItoACAD	"hp_d17_v"	"simplex.shx"	0.95	""	0
FontMapMItoACAD	"hp_i3098_c"	"txt.shx"	1.07	""	0
FontMapMItoACAD	"hp_i3098_v"	"txt.shx"	0.9	""	0
FontMapMItoACAD	"hp_jasc_c"	"italic.shx"	1.24	""	0
FontMapMItoACAD	"hp_jasc_v"	"italic.shx"	1.15	""	0
FontMapMItoACAD	"isocp"	"isocp___.ttf"	0.77	""	0
FontMapMItoACAD	"osd_default"	"txt.shx"	0.9	""	0
FontMapMItoACAD	"osd_default2"	"txt.shx"	1.07	""	0
FontMapMItoACAD	"osd_default3"	"simplex.shx"	0.95	""	0
FontMapMItoACAD	"tahoma"	"tahoma.ttf"	1.25	""	0
FontMapMItoACAD	"times_new_roman"	"TIMES.TTF"	1.03	""	0
FontMapMI2toACAD	"hp_kanj2_c"	"msmincho.ttc"	0.89	"MS Mincho"	32785
FontMapMI2toACAD	"hp_kanji_c"	"msmincho.ttc"	0.89	"MS Mincho"	32785
ArrowMapACADtoMI	" "	Arrow	1	ON
ArrowMapACADtoMI	"_ARCHTICK"	Slash	1	OFF
ArrowMapACADtoMI	"_BOXBLANK"	Arrow	1	OFF
ArrowMapACADtoMI	"_BOXFILLED"	Arrow	1	ON
ArrowMapACADtoMI	"_CLOSED"	Arrow	1	OFF
ArrowMapACADtoMI	"_CLOSEDBLANK"	Arrow	1	OFF
ArrowMapACADtoMI	"_DATUMBLANK"	Triangle	1	OFF
ArrowMapACADtoMI	"_DATUMFILLED"	Triangle	1	ON
ArrowMapACADtoMI	"_DOT"	Dot	1	ON
ArrowMapACADtoMI	"_DOTBLANK"	Dot	1	OFF
ArrowMapACADtoMI	"_DOTSMALL"	Dot	0.5	ON
ArrowMapACADtoMI	"_INTEGRAL"	Slash	1	ON
ArrowMapACADtoMI	"_NONE"	NoArrow	1	ON
ArrowMapACADtoMI	"_OBLIQUE"	Slash	1	OFF
ArrowMapACADtoMI	"_OPEN"	Jis	1	ON
ArrowMapACADtoMI	"_OPEN30"	Jis	1	OFF
ArrowMapACADtoMI	"_OPEN90"	Jis	1	ON
ArrowMapACADtoMI	"_ORIGIN"	Dot	1	OFF
ArrowMapMItoACAD	NoArrow	OFF	"_NONE"	1
ArrowMapMItoACAD	NoArrow	ON	"_NONE"	1
ArrowMapMItoACAD	Arrow	OFF	"_CLOSED"	1
ArrowMapMItoACAD	Arrow	ON	" "	1
ArrowMapMItoACAD	Dot	OFF	"_ORIGIN"	1
ArrowMapMItoACAD	Dot	ON	"_DOT"	1
ArrowMapMItoACAD	Slash	OFF	"_OBLIQUE"	1
ArrowMapMItoACAD	Slash	ON	"_OBLIQUE"	1
ArrowMapMItoACAD	Triangle	OFF	"_DATUMBLANK"	1
ArrowMapMItoACAD	Triangle	ON	"_DATUMFILLED"	1
ArrowMapMItoACAD	Jis	OFF	"_OPEN30"	1
ArrowMapMItoACAD	Jis	ON	"_OPEN30"	1
LinetypeMapACADtoMI	"CENTER_DASH_DASH"	CenterDashDash
LinetypeMapACADtoMI	"CONTINUOUS"	Solid
LinetypeMapACADtoMI	"DASHED"	Dashed
LinetypeMapACADtoMI	"DASH_CENTER"	DashCenter
LinetypeMapACADtoMI	"DOTTED"	Dotted
LinetypeMapACADtoMI	"DOT_CENTER"	DotCenter
LinetypeMapACADtoMI	"LONG_DASHED"	LongDashed
LinetypeMapACADtoMI	"PHANTOM"	Phantom

-------------------------------------------------
No errors encountered during translation.