Mesh API: Difference between revisions
(Created page with 'The Mesh objects can be manipulated by adding new facets, deleting facets, importing from an STL file, transforming the mesh and much more. For a complete overview of what can be…') |
m (add {{APIProperty|CountEdges|the number of vertices of the mesh object.}}) |
||
(16 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
|||
⚫ | The Mesh objects can be manipulated by adding new facets, deleting facets, importing from an STL file, transforming the mesh and much more. For a complete overview of what can be done see also the [[Mesh |
||
<translate> |
|||
<!--T:5--> |
|||
⚫ | |||
{{VeryImportantMessage|(November 2018) This information may be incomplete and outdated. For the latest API, see the [https://www.freecadweb.org/api autogenerated API documentation].}} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
<!--T:1--> |
|||
⚫ | The Mesh objects can be manipulated by adding new facets, deleting facets, importing from an STL file, transforming the mesh and much more. For a complete overview of what can be done see also the [[Mesh_Workbench|Mesh Workbench]] documentation. A mesh object cannot be added to an existing document directly. Therefore the document must create an object with a property class that supports meshes. Example: |
||
<!--T:2--> |
|||
{{Code|code= |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
}} |
|||
<!--T:3--> |
|||
{{APIFunction|addFacet|Facet|Adds a facet to the mesh| }} |
{{APIFunction|addFacet|Facet|Adds a facet to the mesh| }} |
||
{{APIFunction|addFacets|list|Adds a list of facets to the mesh| }} |
{{APIFunction|addFacets|list|Adds a list of facets to the mesh| }} |
||
Line 17: | Line 29: | ||
{{APIFunction|collapseFacets|list|Removes a list of facets| }} |
{{APIFunction|collapseFacets|list|Removes a list of facets| }} |
||
{{APIFunction|copy| |Creates a copy of this mesh|a Mesh object}} |
{{APIFunction|copy| |Creates a copy of this mesh|a Mesh object}} |
||
{{APIFunction|countComponents| |Get the number of |
{{APIFunction|countComponents| |Get the number of topological independent areas|an integer}} |
||
{{APIFunction|countNonUniformOrientedFacets| |Get the number of wrong oriented facets|an integer}} |
{{APIFunction|countNonUniformOrientedFacets| |Get the number of wrong oriented facets|an integer}} |
||
{{APIFunction|countSegments| |Get the number of segments which may also be 0|an integer}} |
{{APIFunction|countSegments| |Get the number of segments which may also be 0|an integer}} |
||
Line 29: | Line 41: | ||
{{APIFunction|flipNormals| |Flip the mesh normals| }} |
{{APIFunction|flipNormals| |Flip the mesh normals| }} |
||
{{APIFunction|foraminate| |Get a list of facet indices and intersection points| }} |
{{APIFunction|foraminate| |Get a list of facet indices and intersection points| }} |
||
{{APIFunction|getPlanes| |Get all planes of the mesh as segment. In the worst case each triangle can be regarded as single plane if none of its |
{{APIFunction|getPlanes| |Get all planes of the mesh as segment. In the worst case each triangle can be regarded as single plane if none of its neighbors is coplanar.| }} |
||
{{APIFunction|getSegment|integer|Get a list of facet indices that describes a segment| }} |
{{APIFunction|getSegment|integer|Get a list of facet indices that describes a segment| }} |
||
{{APIFunction|getSeparateComponents| |Returns a list containing the different components (separated areas) of the mesh as separate meshes|a list}} |
{{APIFunction|getSeparateComponents| |Returns a list containing the different components (separated areas) of the mesh as separate meshes|a list}} |
||
Line 41: | Line 53: | ||
{{APIFunction|isSolid| |Check if the mesh is a solid| }} |
{{APIFunction|isSolid| |Check if the mesh is a solid| }} |
||
{{APIFunction|meshFromSegment| |Create a mesh from segment| }} |
{{APIFunction|meshFromSegment| |Create a mesh from segment| }} |
||
{{APIFunction|nearestFacetOnRay|tuple, tuple|Get the index and intersection point of the nearest facet to a ray. The first parameter is a tuple of three floats the base point of the ray, the second parameter is ut uple of three floats for the direction. The result is a dictionary with an index and the intersection point or an empty dictionary if there is no intersection.|a |
{{APIFunction|nearestFacetOnRay|tuple, tuple|Get the index and intersection point of the nearest facet to a ray. The first parameter is a tuple of three floats the base point of the ray, the second parameter is ut uple of three floats for the direction. The result is a dictionary with an index and the intersection point or an empty dictionary if there is no intersection.|a dictionary}} |
||
{{APIFunction|offset|float|Move the point along their normals| }} |
{{APIFunction|offset|float|Move the point along their normals| }} |
||
{{APIFunction|offsetSpecial|float|Move the point along their normals| }} |
{{APIFunction|offsetSpecial|float|Move the point along their normals| }} |
||
Line 63: | Line 75: | ||
{{APIFunction|splitEdges| |Split all edges| }} |
{{APIFunction|splitEdges| |Split all edges| }} |
||
{{APIFunction|splitFacet| |Split facet| }} |
{{APIFunction|splitFacet| |Split facet| }} |
||
{{APIFunction|swapEdge| |Swap the common edge with the |
{{APIFunction|swapEdge| |Swap the common edge with the neighbor| }} |
||
{{APIFunction|transform| |Apply a transformation to the mesh| }} |
{{APIFunction|transform| |Apply a transformation to the mesh| }} |
||
{{APIFunction|transformToEigen| |Transform the mesh to its eigenbase| }} |
{{APIFunction|transformToEigen| |Transform the mesh to its eigenbase| }} |
||
Line 71: | Line 83: | ||
{{APIFunction|writeInventor| |Write the mesh in OpenInventor format to a string.|a string}} |
{{APIFunction|writeInventor| |Write the mesh in OpenInventor format to a string.|a string}} |
||
{{APIProperty|Area|the area of the mesh object.}} |
{{APIProperty|Area|the area of the mesh object.}} |
||
{{APIProperty|CountEdges|the number of vertices of the mesh object.}} |
|||
{{APIProperty|CountFacets|the number of facets of the mesh object.}} |
{{APIProperty|CountFacets|the number of facets of the mesh object.}} |
||
{{APIProperty|CountPoints|the number of |
{{APIProperty|CountPoints|the number of points of the mesh object.}} |
||
{{APIProperty|Facets|A collection of facets; With this attribute it is possible to get access to the facets of the mesh: for |
{{APIProperty|Facets|A collection of facets; With this attribute it is possible to get access to the facets of the mesh: for f in mesh.Facets: print f. Facet.Points is a list of coordinate-tupels for the vertices. Facet.PointIndices is a list of indice for the vertices of the facet. WARNING! store Facets in a local variable as it is generated on the fly, each time it is accessed.}} |
||
{{APIProperty|Points|A collection of the mesh points; With this attribute it is possible to get access to the points of the mesh: for p in mesh.Points: print p.x, p.y, p.z}} |
{{APIProperty|Points|A collection of the mesh points; With this attribute it is possible to get access to the points of the mesh: for p in mesh.Points: print p.x, p.y, p.z,p.Index.WARNING! store Points in a local variable as it is generated on the fly, each time it is accessed.}} |
||
{{APIProperty|Topology|the points and face indices as tuple. Topology[0] is a list of all vertices. Each being a tuple of 3 coordinates. Topology[1] is a list of all polygons. Each being a list of vertex indice into Topology[0] WARNING! store Topology in a local variable as it is generated on the fly, each time it is accessed.}} |
|||
{{APIProperty|Topology|the points and face indices as tuple.}} |
|||
{{APIProperty|Volume|the volume of the mesh object.}} |
{{APIProperty|Volume|the volume of the mesh object.}} |
||
{{APIProperty|BoundBox|the BoundBox of the object}} |
{{APIProperty|BoundBox|the BoundBox of the object}} |
||
Line 81: | Line 94: | ||
{{APIProperty|Placement|the current transformation of the object as placement}} |
{{APIProperty|Placement|the current transformation of the object as placement}} |
||
⚫ | |||
</translate> |
|||
{{Userdocnavi{{#translation:}}}} |
|||
⚫ | |||
[[Category:Poweruser Documentation{{#translation:}}]] |
|||
{{clear}} |
Latest revision as of 17:28, 16 January 2022
The Mesh objects can be manipulated by adding new facets, deleting facets, importing from an STL file, transforming the mesh and much more. For a complete overview of what can be done see also the Mesh Workbench documentation. A mesh object cannot be added to an existing document directly. Therefore the document must create an object with a property class that supports meshes. Example:
m = Mesh.Mesh()
... # Manipulate the mesh
d = FreeCAD.activeDocument() # Get a reference to the actie document
f = d.addObject("Mesh::Feature", "Mesh") # Create a mesh feature
f.Mesh = m # Assign the mesh object to the internal property
d.recompute()
Description: Get the number of wrong oriented facets
Returns: an integer
Description: Get all planes of the mesh as segment. In the worst case each triangle can be regarded as single plane if none of its neighbors is coplanar.
Returns:
Description: Returns a list containing the different components (separated areas) of the mesh as separate meshes
Returns: a list
Description: Checks if the mesh has facets with inconsistent orientation
Returns:
Description: Get the index and intersection point of the nearest facet to a ray. The first parameter is a tuple of three floats the base point of the ray, the second parameter is ut uple of three floats for the direction. The result is a dictionary with an index and the intersection point or an empty dictionary if there is no intersection.
Returns: a dictionary
Description: Remove components with less or equal to number of given facets
Returns:
Returns: A collection of facets; With this attribute it is possible to get access to the facets of the mesh: for f in mesh.Facets: print f. Facet.Points is a list of coordinate-tupels for the vertices. Facet.PointIndices is a list of indice for the vertices of the facet. WARNING! store Facets in a local variable as it is generated on the fly, each time it is accessed.
Returns: A collection of the mesh points; With this attribute it is possible to get access to the points of the mesh: for p in mesh.Points: print p.x, p.y, p.z,p.Index.WARNING! store Points in a local variable as it is generated on the fly, each time it is accessed.
Returns: the points and face indices as tuple. Topology[0] is a list of all vertices. Each being a tuple of 3 coordinates. Topology[1] is a list of all polygons. Each being a list of vertex indice into Topology[0] WARNING! store Topology in a local variable as it is generated on the fly, each time it is accessed.
- Getting started
- Installation: Download, Windows, Linux, Mac, Additional components, Docker, AppImage, Ubuntu Snap
- Basics: About FreeCAD, Interface, Mouse navigation, Selection methods, Object name, Preferences, Workbenches, Document structure, Properties, Help FreeCAD, Donate
- Help: Tutorials, Video tutorials
- Workbenches: Std Base, Arch, Assembly, CAM, Draft, FEM, Inspection, Mesh, OpenSCAD, Part, PartDesign, Points, Reverse Engineering, Robot, Sketcher, Spreadsheet, Surface, TechDraw, Test Framework
- Hubs: User hub, Power users hub, Developer hub