Mesh MeshObject: Difference between revisions

From FreeCAD Documentation
(Marked this version for translation)
mNo edit summary
 
(11 intermediate revisions by 5 users not shown)
Line 2: Line 2:
<translate>
<translate>


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


<!--T:2-->
<!--T:2-->
Line 11: Line 11:


<!--T:4-->
<!--T:4-->
Please note that the [[FEM_Workbench|FEM Workbench]] also uses meshes, but in this case, it uses a different data structure, called [[Fem_FemMesh|Fem FemMesh]] ({{incode|Fem::FemMesh}} class). This information does not apply to that data structure.
Please note that the {{Button|[[Image:Workbench_FEM.svg|16px]] [[FEM_Workbench|FEM Workbench]]}} also uses meshes, but in this case, it uses a different data structure, called [[FEM_Mesh|FEM FemMesh]] ({{incode|Fem::FemMesh}} class). This information does not apply to FEM meshes.


<!--T:5-->
<!--T:5-->
Line 19: Line 19:
{{Caption|Simplified diagram of the relationships between the core objects in the program. The {{incode|Mesh::MeshObject}} class is embedded in the {{incode|Mesh::Feature}} object and from there it is propagated to all objects that are derived from it.}}
{{Caption|Simplified diagram of the relationships between the core objects in the program. The {{incode|Mesh::MeshObject}} class is embedded in the {{incode|Mesh::Feature}} object and from there it is propagated to all objects that are derived from it.}}


== How to use == <!--T:7-->
== Usage == <!--T:7-->


<!--T:8-->
<!--T:8-->
Line 35: Line 35:


<!--T:12-->
<!--T:12-->
{{Emphasis|See also:}} [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]], and [[scripted objects|scripted objects]]. For a full list of attributes and methods, consult the [[Source_documentation|source documentation]], and the [[Std_PythonHelp|Std PythonHelp]] tool.
{{Emphasis|See also:}} [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]], and [[Scripted_objects|scripted objects]]. For a full list of attributes and methods, consult the [[Source_documentation|source documentation]], and the [[Std_PythonHelp|Std PythonHelp]] tool.


<!--T:13-->
<!--T:13-->
All objects derived from {{incode|Mesh::Feature}} will have a [[Mesh_MeshObject|Mesh MeshObject]], which is normally accessible from its {{incode|Mesh}} attribute.
All objects derived from {{incode|Mesh::Feature}} will have a [[Mesh_MeshObject|Mesh MeshObject]], which is normally accessible from its {{incode|Mesh}} attribute.

</translate>
</translate>
{{Code|code=
{{Code|code=
Line 52: Line 53:
<!--T:14-->
<!--T:14-->
A MeshObject has many attributes (variables) and methods that contain information about it, and which allow doing operations with it. These variables and methods can be tested in the [[Python_console|Python console]].
A MeshObject has many attributes (variables) and methods that contain information about it, and which allow doing operations with it. These variables and methods can be tested in the [[Python_console|Python console]].

</translate>
</translate>
{{Code|code=
{{Code|code=
Line 64: Line 66:
obj.Mesh.write("my_file.stl")
obj.Mesh.write("my_file.stl")
}}
}}
<translate>



<!--T:15-->
{{Mesh Tools navi}}
{{Mesh Tools navi{{#translation:}}}}
{{Document objects navi{{#translation:}}}}
{{Userdocnavi}}
{{Userdocnavi{{#translation:}}}}
</translate>

Latest revision as of 11:27, 13 November 2021

Other languages:

Description

A Mesh MeshObject, or formally a Mesh::MeshObject, is a class that defines a mesh data structure in the software. This is similar to the Part TopoShape but for meshes.

Meshes are normally created with the Mesh Workbench, or imported from STL, OBJ, and similar mesh file formats.

Please note that the FEM Workbench also uses meshes, but in this case, it uses a different data structure, called FEM FemMesh (Fem::FemMesh class). This information does not apply to FEM meshes.

Simplified diagram of the relationships between the core objects in the program. The Mesh::MeshObject class is embedded in the Mesh::Feature object and from there it is propagated to all objects that are derived from it.

Usage

The Mesh MeshObject is an object that is assigned to some App DocumentObjects.

In particular, the basic object that handles these types of attributes is the Mesh Feature (Mesh::Feature class). All objects derived from this class will have access to a Mesh MeshObject.

The most notable objects that will have a Mesh MeshObject are the following:

  • Any primitive mesh created with the Mesh Workbench.
  • Any object created by importing an STL, OBJ, and similar mesh format files.

Scripting

See also: FreeCAD Scripting Basics, and scripted objects. For a full list of attributes and methods, consult the source documentation, and the Std PythonHelp tool.

All objects derived from Mesh::Feature will have a Mesh MeshObject, which is normally accessible from its Mesh attribute.

import FreeCAD as App

doc = App.newDocument()
obj = App.ActiveDocument.addObject("Mesh::Cube", "Cube")
App.ActiveDocument.recompute()
print(obj.Mesh)

A MeshObject has many attributes (variables) and methods that contain information about it, and which allow doing operations with it. These variables and methods can be tested in the Python console.

print(obj.Mesh.Area)
print(obj.Mesh.BoundBox)
print(obj.Mesh.CountPoints)
print(obj.Mesh.Volume)

obj.Mesh.copy()
obj.Mesh.countComponents()
obj.Mesh.getEigenSystem()
obj.Mesh.write("my_file.stl")