Mesh Scripting: Difference between revisions

From FreeCAD Documentation
No edit summary
No edit summary
Line 18: Line 18:
mesh = Mesh.Mesh('D:/temp/Something.stl')
mesh = Mesh.Mesh('D:/temp/Something.stl')


What file formats you can use to build up a mesh is noted [[Feature_list#IO|hier]].
Or create it out of an set of triangles descript by its cornerpoints:

Or create it out of an set of triangles described by its corner points:


planarMesh = [
planarMesh = [
Line 28: Line 30:
planarMeshObject = Mesh.Mesh(planarMesh)
planarMeshObject = Mesh.Mesh(planarMesh)


The Mesh-Kernel takes care about creating an topological correct data structure by sorting
coincident points and edges together.


Later on you will see how you can test and examine mesh data.



== Modeling ==
== Modeling ==

Revision as of 18:02, 16 September 2007

Introduction

First of all you have to import the Mesh module:

import Mesh

After that you have access to the Mesh module and the Mesh class which facilitate the functions of the FreeCAD C++ Mesh-Kernel.

Creation and Loading

To create an empty mesh object just use the standard constructor:

mesh = Mesh.Mesh()

You can also create an object from an file

mesh = Mesh.Mesh('D:/temp/Something.stl')

What file formats you can use to build up a mesh is noted hier.

Or create it out of an set of triangles described by its corner points:

planarMesh = [
# triangle 1
[-0.5000,-0.5000,0.0000],[0.5000,0.5000,0.0000],[-0.5000,0.5000,0.0000],
#triangle 2
[-0.5000,-0.5000,0.0000],[0.5000,-0.5000,0.0000],[0.5000,0.5000,0.0000],
]
planarMeshObject = Mesh.Mesh(planarMesh)

The Mesh-Kernel takes care about creating an topological correct data structure by sorting coincident points and edges together.

Later on you will see how you can test and examine mesh data.

Modeling

Examining and Testing

Write your own Algorithems

Exporting

Gui related stuff

Odds and Ends

An extensive, ought hard to use, source of Mesh related scripting are the unit test scripts of the Mesh-Module. In this unit tests literally all methods are called and all properties/attributes are tweaked. So if you bold enought, take a look at the Unit Test module.