Środowisko pracy OpenSCAD

From FreeCAD Documentation
Revision as of 09:52, 22 May 2022 by Kaktus (talk | contribs) (Created page with "W wersji FreeCAD 0.19 moduł Ply ''(Python-Lex-Yacc)'', który jest używany do importowania plików CSG, został usunięty z kodu źródłowego FreeCAD, ponieważ jest to bib...")
Ikonka FreeCAD dla Środowiska pracy OpenSCAD

Wprowadzenie

Środowisko pracy OpenSCAD służy do zapewnienia interoperacyjności z oprogramowaniem OpenSCAD. Program ten nie jest częścią projektu FreeCAD i by zapewnić pełną funkcjonalność tego środowiska należy zainstalować go samodzielnie.

OpenSCAD nie powinien być mylony z OpenCASCADE będącym nierozłącznym komponentem FreeCAD odpowiedzialnym za opis geometrii. Instalacja oprogramowania OpenSCAD jest w pełni opcjonalna.

It contains a CSG importer to open the CSG files from OpenSCAD, and an exporter to output a CSG based tree. Geometry which is not based on CSG operations will be exported as a mesh.

This workbench contains functions to modify the CSG feature tree and repair models. It also contains general purpose tools that do not require installation of OpenSCAD; they can be used in conjunction with other workbenches. For example, the Mesh Workbench internally uses the OpenSCAD functions to perform operations with meshes, as they are quite robust.

Zależności

W wersji FreeCAD 0.19 moduł Ply (Python-Lex-Yacc), który jest używany do importowania plików CSG, został usunięty z kodu źródłowego FreeCAD, ponieważ jest to biblioteka zewnętrzna, która nie została opracowana przez zespół FreeCAD. W rezultacie musisz teraz zainstalować Ply przed użyciem środowiska OpenSCAD. W przypadku używania wstępnie spakowanej, stabilnej wersji FreeCAD zależność ta powinna być zainstalowana automatycznie na wszystkich platformach; w innych przypadkach, na przykład podczas kompilowania ze źródeł, może być konieczne zainstalowanie jej z repozytorium online.

W dystrybucjach opartych o openSUSE środowisko może zostać zainstalowane za pomocą:

sudo zypper install python3-ply

W dystrybucjach opartych o Debian / Ubuntu środowisko może zostać zainstalowane za pomocą:

sudo apt install python3-ply

Ogólna instalacja na wszystkich platformach może być wykonana z indeksu pakietów Pythona.

pip3 install --user ply

Język OpenSCAD i format pliku

Język OpenSCAD pozwala na używanie zmiennych i pętli. Pozwala on na określenie modułów podrzędnych w celu ponownego użycia geometrii i kodu. Ten wysoki stopień elastyczności sprawia, że parsowanie kodu jest bardzo złożone. Obecnie środowisko OpenSCAD nie obsługuje natywnie języka OpenSCAD. Zamiast tego, jeśli OpenSCAD jest zainstalowany, może być użyty do konwersji danych wejściowych do formatu CSG, który jest podzbiorem języka OpenSCAD i może być użyty jako dane wejściowe do OpenSCAD do dalszej obróbki. Podczas konwersji wszystkie parametry są tracone, co oznacza, że wszystkie nazwy zmiennych są usuwane, pętle rozwijane, a wyrażenia matematyczne obliczane.

Przybory

Ustawienia

  • Preferencje: ustawienia dostępne dla środowiska OpenSCAD.

Ograniczenia

OpenSCAD creates constructive solid geometry, as well as imports mesh files and extrudes 2D geometry from DXF files. FreeCAD allows you to create CSG with primitives as well. The FreeCAD geometry kernel (OCCT) works using a boundary representation. Therefore conversion from CSG to BREP should, in theory, be possible whereas conversion from BREP to CSG is, in general, not.

OpenSCAD works internally on meshes. Some operations which are useful on meshes are not meaningful on a BREP model and can not be fully supported. Among these are convex hull, minkowski sum, glide and subdiv. Currently we run the OpenSCAD binary in order to perform hull and minkwoski operations and import the result. This means that the involved geometry will be triangulated. In OpenSCAD non-uniform scaling is often used, which does not impose any problems when using meshes. In our geometry kernel geometric primitives (lines, circular sections, etc) are converted to BSpline prior to performing such deformations. Those BSplines are known to cause trouble in later boolean operations. An automatic solution is not available at the moment. Please feel free to post to the forum if you encounter such problems. Often such problems can be solved be remodeling small parts. A deformation of a cylinder can substituted by an extrusion of an ellipses.

Importing text

Importing OpenSCAD code with texts requires that the fonts that are used are properly installed on your system. You can verify this by opening OpenSCAD as a standalone tool and checking the list in Help → Font List. The list will also give you the correct font names. If a font does not appear in the list after installing, you may have to manually copy the font file to the appropriate system directory.

Importing texts is relatively slow. Behind the scenes FreeCAD uses a DXF file created by OpenSCAD. The more contours there are the slower the import.

It can be a good idea to first import a simple test case (replace NameOfFont with the correct font name):

TESTFONT="NameOfFont";
linear_extrude(0.001) {
  text("A", size=5, font=TESTFONT, script="Latn");
};

The script="Latn" parameter can be left out here, but is required if the text string does not contain any letters, but only punctuation and/or numbers.

Please note that use <FONT>; statements in your source files are ignored when importing in FreeCAD. Under OpenSCAD the effect of a use statement is that the provided font file is temporarily added to the list of known fonts (although even there the statement does not work when a script is modified interactively).

Wskazówki

Podczas importowania plików w formacie DXF ustaw precyzję szkicu na rozsądną wartość, ponieważ będzie to miało wpływ na wykrywanie połączonych krawędzi.

Jeśli program FreeCAD zawiesza się podczas importowania pliku CSG, zaleca się włączenie opcji "Automatycznie sprawdź model po operacji logicznej" w menu Edycja → Preferencje ... → Projekt Części → Ogólne → Ustawienia modelu.

Poradniki

Odnośniki internetowe