Create mesh with correct faces in Blender by Python script

This video tutorial explains how to create mesh using Python script.

Vertices must be defined in right order when we want to define correct face.

Let’s imagine that we would like to create following object:

Numbers are marking vertices beginning from 0.

Let’s define them:

faces = ((0,1,2,3), (1,2,6,5), (1,0,4,5), (2,3,7,6), (0,3,7,4), (4,5,6,7)

Just display normals to see whether everything is ok.

As you can see, only few faces have correct normal.

In order to define face correctly use following rule:

Imagine that you’re sitting inside object and you’re looking outside.

You have to define face by naming vertices in clockwise fashion.

Solution is:

faces = ((0,1,2,3), (5,6,2,1), (4,5,1,0), (2,6,7,3), (0,3,7,4),(7,6,5,4))

For more details about Python and Blender pay a visit to blendercookie.com.

No votes yet.
Please wait...

Leave a comment

22. June 2011 at 21:21 - Graphics (Tags: , , , ). Both comments and pings are currently closed.

2 Responses to “Create mesh with correct faces in Blender by Python script”

  • Pradeep says:

    Good work.
    Thanks a lot.
    If you can, please help me to create a house with python scripts.
    (rooms,doors,windows,etc)

    Thanks

    No votes yet.
    Please wait...
  • cuneyt says:

    http://blenderartists.org/forum/showthread.php?270422-AddOn-Window-Generator-2

    No votes yet.
    Please wait...