Mesh FromPartShape: Difference between revisions

From FreeCAD Documentation
No edit summary
(Marked this version for translation)
(40 intermediate revisions by one other user not shown)
Line 1: Line 1:
<languages/>
<languages/>

{{Page in progress}}

<translate>
<translate>


<!--T:1-->
{{Docnav
{{Docnav
|[[Mesh_Export|Mesh Export]]
|[[Mesh_Export|Mesh Export]]
Line 14: Line 12:
}}
}}


<!--T:2-->
{{GuiCommand
{{GuiCommand
|Name=Mesh FromPartShape
|Name=Mesh FromPartShape
Line 20: Line 19:
}}
}}


==Description==
==Description== <!--T:26-->


<!--T:3-->
The '''Mesh FromPartShape''' command creates a non-parametric mesh object, a [[Mesh_Feature|Mesh Feature]], from a shape object.
The '''Mesh FromPartShape''' command creates non-parametric mesh objects, [[Mesh_Feature|Mesh Features]], from shape objects.


==Usage==
==Usage== <!--T:4-->


<!--T:5-->
# Optionally select one or more objects.
# Optionally select one or more objects.
# There are several ways to invoke the command:
# There are several ways to invoke the command:
#* Press the {{Button|[[Image:Mesh_FromPartShape.svg|16px]] [[Mesh_Export|Mesh FromPartShape]]}} button.
#* Press the {{Button|[[Image:Mesh_FromPartShape.svg|16px]] [[Mesh_FromPartShape|Mesh FromPartShape]]}} button.
#* Select the {{MenuCommand|Meshes → [[Image:Mesh_FromPartShape.svg|16px]] Create mesh from shape...}} option from the menu.
#* Select the {{MenuCommand|Meshes → [[Image:Mesh_FromPartShape.svg|16px]] Create mesh from shape...}} option from the menu.
# The Tessellation task panel opens.
# The {{MenuCommand|Tessellation}} task panel opens.
# While the task panel is open you can create a (new) selection or change an existing selection.
# While the task panel is open you can create a new selection or change an existing selection.
# Select the tab for the mesher program you wish to use.
# Select the tab for the mesher you wish to use.
# Specify the required settings. See [[#Mesher_programs|Mesher programs]].
# Specify the required settings. See [[#Meshers|Meshers]].
# Press the {{Button|OK}} button to close the task panel and finish the command.
# Press the {{Button|OK}} button to close the task panel and finish the command.


==Meshers== <!--T:7-->
==Mesher programs==


<!--T:8-->
These are the available mesher programs and their settings:
These are the available meshers and their settings:


===Standard===
===Standard mesher=== <!--T:9-->


<!--T:11-->
* {{MenuCommand|Surface deviation}}: the maximum [https://www.opencascade.com/doc/occt-7.3.0/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_11_2 linear deviation] of a mesh section from the surface of the object.
* {{MenuCommand|Surface deviation}}: the maximum [https://www.opencascade.com/doc/occt-7.3.0/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_11_2 linear deviation] of a mesh section from the surface of the object.
* {{MenuCommand|Angular deviation}}: the maximum [https://www.opencascade.com/doc/occt-7.3.0/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_11_2 angular deviation] from one mesh section to the next. Used when meshing curved surfaces.
* {{MenuCommand|Angular deviation}}: the maximum [https://www.opencascade.com/doc/occt-7.3.0/overview/html/occt_user_guides__modeling_algos.html#occt_modalg_11_2 angular deviation] from one mesh section to the next. This setting is used when meshing curved surfaces.
* {{MenuCommand|Relative surface deviation}}: if checked, the maximum linear deviation of a mesh segment will be the specified ''Surface deviation'' multiplied by the length of the current mesh segment (edge).
* {{MenuCommand|Relative surface deviation}}: if checked, the maximum linear deviation of a mesh segment will be the specified {{MenuCommand|Surface deviation}} multiplied by the length of the current mesh segment (edge).
* {{MenuCommand|Apply face colors to mesh}}: If checked, the mesh will get the face colors of the object.
* {{MenuCommand|Apply face colors to mesh}}: if checked, the mesh will get the face colors of the object.
* {{MenuCommand|Define segments by face colors}}: If checked, mesh segments will be grouped according to the colors of the object's faces. These groups will be exported for mesh output formats supporting this feature (the [https://en.wikipedia.org/wiki/Wavefront_.obj_file OBJ] format for example).
* {{MenuCommand|Define segments by face colors}}: if checked, mesh segments will be grouped according to the colors of the object's faces. These groups will be exported for mesh output formats supporting this feature (the [https://en.wikipedia.org/wiki/Wavefront_.obj_file OBJ] format for example).


===Mefisto===
===Mefisto mesher=== <!--T:12-->


<!--T:14-->
* {{MenuCommand|Maximum edge length}}: the maximum edge length of the mesh. If this number is smaller the mesh becomes finer. Specifying {{Value|0}}, or unchecking the checkbox, results in a very coarse mesh.
* {{MenuCommand|Maximum edge length}}: the maximum edge length of the mesh. A smaller value results in a finer mesh. Specifying {{Value|0}}, or unchecking the checkbox, results in a very coarse mesh.
* If you press the {{Button|Estimate}} button the mesher will enter a suggested value for the ''Maximum edge length''.
** If you press the {{Button|Estimate}} button the mesher will enter an estimated value for the {{MenuCommand|Maximum edge length}}. This value is not very reliable if multiple objects have been selected.


===Netgen===
===Netgen mesher=== <!--T:15-->


<!--T:17-->
===Gmsh===
* {{MenuCommand|Fineness}}: select an options for the finesse of the mesh:
** {{MenuCommand|Very coarse}}
** {{MenuCommand|Coarse}}
** {{MenuCommand|Moderate}}
** {{MenuCommand|Fine}}
** {{MenuCommand|Very fine}}
** {{MenuCommand|User defined}}: for this option the following settings can be specified:
*** {{MenuCommand|Mesh size grading}}: a smaller value results in a finer mesh. The value must be in the {{Value|0.1}} - {{Value|1.0}} range.
*** {{MenuCommand|Element per edge}}: a larger value results in a finer mesh. The value must be in the {{Value|0.2}} - {{Value|10.0}} range.
*** {{MenuCommand|Element per curvature radius}}: a larger value results in a finer mesh. The value must be in the {{Value|0.2}} - {{Value|10}} range.
*{{MenuCommand|Optimize surface}}: if checked, the surface shape will be optimized.
*{{MenuCommand|Second order elements}}: if checked, second order elements will be generated resulting in a finer mesh.
*{{MenuCommand|Quad dominated}}: if checked, the mesh will preferably use [https://en.wikipedia.org/wiki/Types_of_mesh#Two-dimensional quadrilateral faces].


===Gmsh mesher=== <!--T:27-->


<!--T:28-->
* Press {{KEY|Esc}} or the {{Button|Cancel}} button to abort the command.
{{Version|0.19}}


<!--T:29-->
==Notes==
For Linux users: the external [https://gmsh.info/ Gmsh] module is required.


<!--T:30-->
* Todo.
* {{MenuCommand|Meshing}}: select a meshing option:
** {{MenuCommand|Automatic}}
** {{MenuCommand|Adaptive}}
** {{MenuCommand|Delaunay}}
** {{MenuCommand|Frontal}}
** {{MenuCommand|BAMG}}
** {{MenuCommand|Frontal Quad}}
** {{MenuCommand|Parallelograms}}
* {{MenuCommand|Max. element size}}: a smaller value results in a finer mesh. Specify {{Value|0}} to have this size automatically determined.
* {{MenuCommand|Min. element size}}: a smaller value results in a finer mesh. The value should be smaller than the {{MenuCommand|Max. element size}}. Specify {{Value|0}} to have this size automatically determined.
* {{MenuCommand|Angle}}: seems to be unsupported at this time.
* {{MenuCommand|Path}}: press the {{Button|...}} button and browse to the {{FileName|gmsh.exe}} path.
* If the meshing process takes too long you can press the {{Button|Kill}} button to abort it.
* Press the {{Button|Clear}} button to remove the information in the text area. <!--Because the task panel closes the Clear button cannot be used with this command. But the same task panel is used for the Mesh_RemeshGmsh command-->


==Notes== <!--T:22-->
==Preferences==


<!--T:31-->
* Todo.
* This command is not restricted to objects created with the [[Part_Module|Part workbench]]. It can create a mesh from any object that has a shape including objects created with the [[PartDesign_Workbench|PartDesign workbench]].
* The [[Std_Export|Std Export]] command can export shape objects directly to a mesh format.
* See also: [[Export_to_STL_or_OBJ|Export to STL or OBJ]] tutorial.


==Preferences== <!--T:32-->
==Properties==


===Standard mesher=== <!--T:33-->
See [[Mesh_Feature|Mesh Feature]].


<!--T:34-->
==Scripting==
* The {{MenuCommand|Surface deviation}} setting is stored: {{MenuCommand|Tools → Edit parameters... → BaseApp → Preferences → Mod → Mesh → Meshing → Standard → LinearDeflection}}.
* The {{MenuCommand|Angular deviation}} setting is stored: {{MenuCommand|Tools → Edit parameters... → BaseApp → Preferences → Mod → Mesh → Meshing → Standard → AngularDeflection}}.
* The {{MenuCommand|Relative surface deviation}} setting is stored: {{MenuCommand|Tools → Edit parameters... → BaseApp → Preferences → Mod → Mesh → Meshing → Standard → RelativeLinearDeflection}}.

===Gmsh mesher=== <!--T:35-->

<!--T:36-->
* The {{MenuCommand|Path}} is stored: {{MenuCommand|Tools → Edit parameters... → BaseApp → Preferences → Mod → Mesh → Meshing → gmshExe}}.

==Properties== <!--T:37-->

<!--T:38-->
See: [[Mesh_Feature|Mesh Feature]].

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

<!--T:39-->
See also: [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]].

<!--T:20-->
To create a mesh object from a shape object use the {{incode|meshFromShape}} method of the MeshPart module. This method has several signatures. The signature determines the mesher that will be used. The example below uses the Mefisto mesher signature.

</translate>
{{Code|code=
import FreeCAD, Part, Mesh, MeshPart

cyl = FreeCAD.ActiveDocument.addObject("Part::Cylinder","Cylinder")
FreeCAD.ActiveDocument.recompute()

msh = FreeCAD.ActiveDocument.addObject("Mesh::Feature", "Mesh")
msh.Mesh = MeshPart.meshFromShape(Shape=cyl.Shape, MaxLength=1)
msh.ViewObject.DisplayMode = "Flat Lines"
}}
<translate>


* Todo.


<!--T:23-->
{{Docnav
{{Docnav
|[[Mesh_Export|Mesh Export]]
|[[Mesh_Export|Mesh Export]]

Revision as of 21:09, 21 July 2020

Mesh FromPartShape

Menu location
Meshes → Create mesh from shape...
Workbenches
Mesh
Default shortcut
None
Introduced in version
-
See also
None

Description

The Mesh FromPartShape command creates non-parametric mesh objects, Mesh Features, from shape objects.

Usage

  1. Optionally select one or more objects.
  2. There are several ways to invoke the command:
    • Press the Mesh FromPartShape button.
    • Select the Meshes → Create mesh from shape... option from the menu.
  3. The Tessellation task panel opens.
  4. While the task panel is open you can create a new selection or change an existing selection.
  5. Select the tab for the mesher you wish to use.
  6. Specify the required settings. See Meshers.
  7. Press the OK button to close the task panel and finish the command.

Meshers

These are the available meshers and their settings:

Standard mesher

  • Surface deviation: the maximum linear deviation of a mesh section from the surface of the object.
  • Angular deviation: the maximum angular deviation from one mesh section to the next. This setting is used when meshing curved surfaces.
  • Relative surface deviation: if checked, the maximum linear deviation of a mesh segment will be the specified Surface deviation multiplied by the length of the current mesh segment (edge).
  • Apply face colors to mesh: if checked, the mesh will get the face colors of the object.
  • Define segments by face colors: if checked, mesh segments will be grouped according to the colors of the object's faces. These groups will be exported for mesh output formats supporting this feature (the OBJ format for example).

Mefisto mesher

  • Maximum edge length: the maximum edge length of the mesh. A smaller value results in a finer mesh. Specifying 0, or unchecking the checkbox, results in a very coarse mesh.
    • If you press the Estimate button the mesher will enter an estimated value for the Maximum edge length. This value is not very reliable if multiple objects have been selected.

Netgen mesher

  • Fineness: select an options for the finesse of the mesh:
    • Very coarse
    • Coarse
    • Moderate
    • Fine
    • Very fine
    • User defined: for this option the following settings can be specified:
      • Mesh size grading: a smaller value results in a finer mesh. The value must be in the 0.1 - 1.0 range.
      • Element per edge: a larger value results in a finer mesh. The value must be in the 0.2 - 10.0 range.
      • Element per curvature radius: a larger value results in a finer mesh. The value must be in the 0.2 - 10 range.
  • Optimize surface: if checked, the surface shape will be optimized.
  • Second order elements: if checked, second order elements will be generated resulting in a finer mesh.
  • Quad dominated: if checked, the mesh will preferably use quadrilateral faces.

Gmsh mesher

introduced in version 0.19

For Linux users: the external Gmsh module is required.

  • Meshing: select a meshing option:
    • Automatic
    • Adaptive
    • Delaunay
    • Frontal
    • BAMG
    • Frontal Quad
    • Parallelograms
  • Max. element size: a smaller value results in a finer mesh. Specify 0 to have this size automatically determined.
  • Min. element size: a smaller value results in a finer mesh. The value should be smaller than the Max. element size. Specify 0 to have this size automatically determined.
  • Angle: seems to be unsupported at this time.
  • Path: press the ... button and browse to the gmsh.exe path.
  • If the meshing process takes too long you can press the Kill button to abort it.
  • Press the Clear button to remove the information in the text area.

Notes

Preferences

Standard mesher

  • The Surface deviation setting is stored: Tools → Edit parameters... → BaseApp → Preferences → Mod → Mesh → Meshing → Standard → LinearDeflection.
  • The Angular deviation setting is stored: Tools → Edit parameters... → BaseApp → Preferences → Mod → Mesh → Meshing → Standard → AngularDeflection.
  • The Relative surface deviation setting is stored: Tools → Edit parameters... → BaseApp → Preferences → Mod → Mesh → Meshing → Standard → RelativeLinearDeflection.

Gmsh mesher

  • The Path is stored: Tools → Edit parameters... → BaseApp → Preferences → Mod → Mesh → Meshing → gmshExe.

Properties

See: Mesh Feature.

Scripting

See also: FreeCAD Scripting Basics.

To create a mesh object from a shape object use the meshFromShape method of the MeshPart module. This method has several signatures. The signature determines the mesher that will be used. The example below uses the Mefisto mesher signature.

import FreeCAD, Part, Mesh, MeshPart

cyl = FreeCAD.ActiveDocument.addObject("Part::Cylinder","Cylinder")
FreeCAD.ActiveDocument.recompute()

msh = FreeCAD.ActiveDocument.addObject("Mesh::Feature", "Mesh")
msh.Mesh = MeshPart.meshFromShape(Shape=cyl.Shape, MaxLength=1)
msh.ViewObject.DisplayMode = "Flat Lines"