OpenSCAD User Manual/STL ファイルのインポートとエクスポート

テンプレート:Incomplete

import 文 編集

OpenSCAD のモデリングに用いる STL ファイルをインポートする。

引数

<file>
文字列。STL または DXF ファイルのパス名。
<convexity>
整数。convexity (凸度) は、オブジェクトの表面を光線が突き抜けるときに面と交差する回数の最大値。

OpenCSGで正しくレンダリングするためだけに必要であり、最終的なレンダリング結果には影響をおよぼさない。

例:

import("example012.stl", convexity=3);
import("D:\\Documents and Settings\\User\\My Documents\\Gear.stl", convexity=3);

(Windows ではパス名中のバックスラッシュはバックスラッシュでエスケープする必要がある)。

Convexity 編集

 

上図は2次元のconvexityが4である例である。赤線は図形と最大4回交差する。 3次元オブジェクトのconvexityも同様に計算される。 大抵のオブジェクトでは、10とすれば十分である。

編集

最新バージョンの OpenSCAD では、import() は2次元のDXFファイル (押し出しのため) および3次元のSTLファイル (オブジェクト) の双方をインポートするために用いられる。

インポートしたSTFファイルを後でレンダリングするために、STL ファイルは "クリーン" な状態でなければならない。 メッシュは manifold (訳注: 閉じた面で囲まれた状態) であり、穴があったり自己交差していてはいけない。 もし STLファイルがクリーンでない場合、下記のようなエラーが出る。

 CGAL error in CGAL_Build_PolySet: CGAL ERROR: assertion violation!
 Expr: check_protocoll == 0
 File: /home/don/openscad_deps/mxe/usr/i686-pc-mingw32/include/CGAL/Polyhedron_incremental_builder_3.h
 Line: 199

あるいは

 CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation!
 Expr: pe_prev->is_border() || !internal::Plane_constructor<Plane>::get_plane(pe_prev->facet(),pe_prev->facet()->plane()).is_degenerate()
 File: /home/don/openscad_deps/mxe/usr/i686-pc-mingw32/include/CGAL/Nef_3/polyhedron_3_to_nef_3.h
 Line: 253

STLファイルをクリーンにするために、下記のような方法がある:

- http://wiki.netfabb.com/Semi-Automatic_Repair_Options の方法を用いる。穴は埋められるが自己交差は削除できない。

- netfabb basic を用いる。このフリーソフトは穴を埋めるオプションも自己交差の削除もできない。

- MeshLab を用いる。このフリーソフトはすべての問題を解決できる。

MeshLab を用いる場合:

- メニュー『Render』→『Show non Manif Edges』を選択する、かつ・または

- メニュー『Render』→ 『Show non Manif Vertices』を選択する。

- もしこれらを用いて、manifoldでない辺や点が見つかったら、メニュー『Filters』→『Selection』→『Select non Manifold Edges』または『Select non Manifold Vertices』 を選択し、『Apply』で実行、『Close』で閉じる。 次に『'Delete the current set of selected vertices...'』ボタンを押す。 Youtubeに http://www.youtube.com/watch?v=oDx0Tgy0UHo この方法の動画がある。 このようにすると "0 non manifold edges"、"0 non manifold vertices" と表示される。

次に、『'Fill Hole'』ボタンを押し、すべての穴を選択し『Accept』ボタンを押す。 以上の操作は複数回繰り返す必要があるかもしれない。

その後、メニュー『File』→『Export Mesh』でSTL形式でセーブする。

import_stl 編集

<DEPRECATED.. Use the command import instead..>

Imports an STL file for use in the current OpenSCAD model

Parameters

<file>
A string containing the path to the STL file to include.
<convexity>
Integer. The convexity parameter specifies the maximum number of front sides (back sides) a ray intersecting the object might penetrate. This parameter is only needed for correctly displaying the object in OpenCSG preview mode and has no effect on the polyhedron rendering.

Usage examples:

import_stl("example012.stl", convexity = 5);