Mesh Scripting: Difference between revisions

From FreeCAD Documentation
No edit summary
Line 9: Line 9:


== Creation and Loading ==
== 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')

Or create it out of an set of triangles descript by its cornerpoints:

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)





== Modeling ==
== Modeling ==

Revision as of 17:56, 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')

Or create it out of an set of triangles descript by its cornerpoints:

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)



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.