OpenSCAD Workbench: Difference between revisions

From FreeCAD Documentation
No edit summary
(Updated description)
(18 intermediate revisions by 7 users not shown)
Line 1: Line 1:
<languages/>
<translate>
<translate>
<!--T:1-->
<!--T:21-->
{{docnav|[[Mesh Module|Mesh Module]]|[[Part Module|Part Module]]|IconL=Workbench_Mesh.svg|IconR=Workbench_Part.svg}}
The OpenSCAD module is in an early stage of development.


</translate>
<!--T:2-->
[[Image:OpenSCADWorkbench.svg|64px]]
The OpenSCAD module offers interoperability with the open source software [http://www.openscad.org/ OpenSCAD].
<translate>


== Introduction == <!--T:1-->

The OpenSCAD Workbench is intended to offer interoperability with the open source software [http://www.openscad.org/ OpenSCAD].
<!--T:3-->
[[Image:OpenSCADexamaple1.png|An example of imported OpenSCAD geometry]]


<!--T:4-->
<!--T:4-->
It contains an [[OpenSCAD_CSG|importer]] which allows you to open the [[OpenSCAD_CSG|.csg]] output from OpenSCAD in FreeCAD.
It contains a [[OpenSCAD_CSG|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.


<!--T:5-->
<!--T:16-->
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.
The [[OpenSCAD_CSG|exporter]] outputs a CSG based (sub-)tree to [[OpenSCAD_CSG|.csg]]. Geometry which is not based on CSG operations and is exported as a mesh.

The OpenSCAD module contains a toolbox with functions to modify the feature tree and repair models.
</translate>
{{TOCright}}
[[Image:OpenSCADexamaple1.png]]
<translate>


== OpenSCAD language and file format == <!--T:6-->
== OpenSCAD language and file format == <!--T:6-->
The OpenSCAD language allows the use of variables and loops. It allows you to specify submodules to reuse geometry and code. This high degree of flexibility makes parsing very complex. Currently the OpenSCAD module in FreeCAD can not handle the OpenSCAD language natively.
Instead, if OpenSCAD is installed, it can be used to convert the input to an output format named 'CSG'. It is a subset of the OpenSCAD Language and can be used as the input to OpenSCAD for further processing.
During conversion all parametric behavior is lost - all variable names are discarded, loops expanded and mathematical expressions evaluated.


== GUI Commands == <!--T:7-->
<!--T:17-->
The OpenSCAD language allows the use of variables and loops. It allows you to specify sub-modules to reuse geometry and code. This high degree of flexibility makes parsing very complex. Currently the OpenSCAD Workbench cannot handle the OpenSCAD language natively.
{{OpenSCAD Tools}}
Instead, if OpenSCAD is installed, it can be used to convert the input to the CSG format, which is a subset of the OpenSCAD language, and can be used as the input to OpenSCAD for further processing.
During conversion all parametric behavior is lost, meaning that all variable names are discarded, loops expanded, and mathematical expressions evaluated.

== Tools == <!--T:7-->

<!--T:18-->
* [[Image:OpenSCAD_ColorCodeShape.png|32px]] [[OpenSCAD_ColorCodeShape|Color Code Shape]]: Change the color of selected or all shapes based on their validity.
* [[Image:OpenSCAD_ReplaceObject.png|32px]] [[OpenSCAD_ReplaceObject|Replace Object]]: Replace an object in the feature tree.
* [[Image:OpenSCAD_RemoveSubtree.png|32px]] [[OpenSCAD_RemoveSubtree|Remove Subtree]]: Removes the selected objects and all children that are not referenced from other objects.
* [[Image:OpenSCAD_RefineShapeFeature.png|32px]] [[OpenSCAD_RefineShapeFeature|Refine Shape Feature]]: Create Refine Shape Feature.
* [[Image:OpenSCAD_IncreaseTolerance.png|32px]] [[OpenSCAD_IncreaseTolerance|Increase Tolerance Feature]]: Increases tolerance of edges/faces/vertex of selected object(s).
* [[Image:OpenSCAD_Edgestofaces.png|32px]] [[OpenSCAD_Edgestofaces|Convert Edges To Faces]]: Convert edges to faces. Useful to prepare imported DXF geometry for extrusion.
* [[Image:OpenSCAD_ExpandPlacements.png|32px]] [[OpenSCAD_ExpandPlacements|Expand Placements]]: Expand all placements downwards the FeatureTree.
* [[Image:OpenSCAD_ExplodeGroup.png|32px]] [[OpenSCAD_ExplodeGroup|Explode Group]]: Explodes fused part primitives.
* [[Image:OpenSCAD_AddOpenSCADElement.png|32px]] [[OpenSCAD_AddOpenSCADElement|Add OpenSCAD Element]]: Add an OpenSCAD element by entering OpenSCAD code into the task panel.
* [[Image:OpenSCAD_MeshBoolean.png|32px]] [[OpenSCAD_MeshBoolean|Mesh Boolean]]: Creates new mesh object by boolean operation from shapes.
* [[Image:OpenSCAD_Hull.png|32px]] [[OpenSCAD_Hull|Hull]]: Applies a hull to selected shapes.
* [[Image:OpenSCAD_Minkowski.png|32px]] [[OpenSCAD_Minkowski|Minkowski]]: Applies a minkowski sum to selected shapes.

== Preferences == <!--T:19-->

<!--T:20-->
* [[Image:Std_DlgParameter.png|32px]] [[OpenSCAD_Preferences|Preferences]]: preferences available for the OpenSCAD tools.


== Limitations == <!--T:8-->
== Limitations == <!--T:8-->
OpenSCAD creates constructive solid geometry as well as importing mesh files and extruding 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.
OpenSCAD creates constructive solid geometry, as well as imports mesh files and extrudes 2D geometry from [[DXF|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.
Therefore conversion from CSG to BREP should, in theory, be possible whereas conversion from BREP to CSG is, in general, not.


<!--T:9-->
<!--T:9-->
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.
OpenSCAD works internaly on meshes. Some operations which are useful on meshes are not meaningful on a BREP model and are currently not available. Among these are convex hull, minkowski sum, glide and subdiv.
OpenSCAD is very tolerant when doing booleans on coincident geometry. The FreeCAD geometry kernel is less tolerant. An automatic solution is not available at the moment. Please feel free to post to the forum if you encounter such problems.


== Hints == <!--T:10-->
== Hints == <!--T:10-->
When importing DXF set the Draft precision to a sensible amount as this will affect the detection of connected edges.
When importing [[DXF|DXF]] set the Draft precision to a sensible amount as this will affect the detection of connected edges.


<!--T:11-->
<!--T:11-->
If FreeCAD crashes when importing CSG, it is strongly recommended that you enable 'automatically check model after boolean operation' in Menu -> Edit -> Preferences -> Part Design -> Model setting
If FreeCAD crashes when importing CSG, it is strongly recommended that you enable "automatically check model after boolean operation" in {{MenuCommand|Menu Edit Preferences Part Design Model setting}}.

== Tutorials == <!--T:15-->
* [[Import_OpenSCAD_code|Import OpenSCAD code]]


== Links == <!--T:12-->
== Links == <!--T:12-->
* [http://www.thingiverse.com/tag:openscad Things tagged with "Openscad" on Thingiverse]
* [https://freecadweb.org/tracker/search.php?tag_string=OpenSCAD Open tickets tagged "Openscad" on the FreeCAD bugtracker]
* [http://www.thingiverse.com/tag:openscad Things tagged with "OpenSCAD" on Thingiverse]


<!--T:13-->
{{docnav|}}
{{docnav|[[Mesh Module|Mesh Module]]|[[Part Module|Part Module]]|IconL=Workbench_Mesh.svg|IconR=Workbench_Part.svg}}


<!--T:22-->
[[Category:User Documentation]]
{{OpenSCAD Tools navi}}
{{Userdocnavi}}
[[Category:Workbenches]]


</translate>
</translate>
{{clear}}
<languages/>

Revision as of 11:39, 19 April 2019

Introduction

The OpenSCAD Workbench is intended to offer interoperability with the open source software OpenSCAD.

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.

OpenSCAD language and file format

The OpenSCAD language allows the use of variables and loops. It allows you to specify sub-modules to reuse geometry and code. This high degree of flexibility makes parsing very complex. Currently the OpenSCAD Workbench cannot handle the OpenSCAD language natively. Instead, if OpenSCAD is installed, it can be used to convert the input to the CSG format, which is a subset of the OpenSCAD language, and can be used as the input to OpenSCAD for further processing. During conversion all parametric behavior is lost, meaning that all variable names are discarded, loops expanded, and mathematical expressions evaluated.

Tools

Preferences

  • Preferences: preferences available for the OpenSCAD tools.

Limitations

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.

Hints

When importing DXF set the Draft precision to a sensible amount as this will affect the detection of connected edges.

If FreeCAD crashes when importing CSG, it is strongly recommended that you enable "automatically check model after boolean operation" in Menu → Edit → Preferences → Part Design → Model setting.

Tutorials

Links