




(Attention starting from here this text could become unpleasing, and perhaps even: tiresome)
We have thus two problems to solve:
range(departure_value, end_value, incremention_value)
If the starting value is 0, the end value
100 and the progression 1, range(0.0,100.0,1) will build a list
whose value which is located at the index [ 0 ] will be 0, with the
index [ 1 ] will be 1 and so on.
If the progression had been two, it would
have been necessary to indicate:
range(0.0,100.0,2),
the value stored
at [ 0 ] would have been: 0.0,
in 1: 2,
in 2: 4,
in 3: 6, etc.
# example of loop python
for i=0 in range(0,100,1): # Here begins the first subroutine # four spaces of indentation ... 
For the second problem it is necessary
to reason a little. Let us imagine one moment a square mesh of polygons
made up of 4 faces having 4 vertices. We would have thus 9 vertices to
distribute. These vertices are arranged, in a list, in the following way
[
0,1,2,3,4,5,6,7,8 ] . With a rapid sketch one sees clearly that
there are three lines of three vertices. The number of lines could be arranged
in a variable "I"and the number of the vertices
in variable "J"
.

The question we can ask is the following
one :
Which value must one allot to variable
I
and
variable
J ? (if we have to use both to reach
the first vertex which is at index 0).
One can pose: (I
relation
J)
=
0, a priori (0 relation 0) = 0, and that appears very usable as for
the next index, the same line
I
continues
to worth 0, but it is necessary to increase the value of J
to
arrive at 1. the relation could be I +
J,
but
is this sufficient ? Indeed the following line
I will
worth1, but to arrive at index 3 the relation i+j will
not give what we hope, as
J will worth initially 0.
In fact it is necessary to multiply I by 3
to obtain the result we are waiting for. The formula which makes it possible
to locate something in this mesh is I*3+j .
But could'nt we replace the value 3
by
a variable which could be determined automatically without any intervention
and according to the total number of vertices of the list ?. Yes. If the
mesh of polygons is square, it will always be the square root of the total
number of vertices of the list. (One can arrive at results with whole division
and the remainder of whole division when the mesh is not square, but it's
another story which we will reserve for another teachware.)
Blender import
from Blender NMesh import # Some mathematical functions of the Python
module
# Creation of the mesh of polygons
# Without tackling the problem of the local
variables
# This is an example of what
we have just explained above
# Just applies systematically
for i=0 in range(0, n, 1):
# Let us make a pause before passing



to the Top 