Mesh creation in Python with 2.25

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

daddy
Posts: 4
Joined: Tue Nov 19, 2002 2:22 am

Mesh creation in Python with 2.25

Postby daddy » Tue Nov 19, 2002 2:31 am

I'm trying to get started creating meshes in Blender 2.25 using Python. I have been successful creating NMeshes - but that seems to be deprocated.

The example script for the Mesh module in the 2.25 python documentation dies trying to load the "tess" module as mandated by "../modules/utils/tesselation.py" as soon as i get to the m.update() method.

Any suggestions ?

jms
Posts: 327
Joined: Sat Oct 19, 2002 3:04 pm

Re: Mesh creation in Python with 2.25

Postby jms » Tue Nov 19, 2002 11:53 am

daddy wrote:I'm trying to get started creating meshes in Blender 2.25 using Python. I have been successful creating NMeshes - but that seems to be deprocated.

The example script for the Mesh module in the 2.25 python documentation dies trying to load the "tess" module as mandated by "../modules/utils/tesselation.py" as soon as i get to the m.update() method.
Any suggestions ?


Are you using linux version?
There was a problem with this function under win32 systems.
Zoo-3D.Blender, Ze French-Speaking Community SKB My french book about Blender.

daddy
Posts: 4
Joined: Tue Nov 19, 2002 2:22 am

Postby daddy » Tue Nov 19, 2002 4:14 pm

I was using windows NT4. I will try it on Suse Linux 7.2 when I get home.

Many thanks

daddy
Posts: 4
Joined: Tue Nov 19, 2002 2:22 am

Postby daddy » Wed Nov 20, 2002 3:28 am

No - still not working.

Here are its dying words...

Traceback (most recent call last):
File "mesh.py", line 32, in ?
m.update() # update and triangulate mesh
File "../modules/Blender/Mesh.py", line 203, in update
File "../modules/Blender/Mesh.py", line 69, in toTriangles
File "../modules/utils/tesselation.py", line 11, in ?
ImportError: No module named tess


If I need to set some kind of path, how would I do it ?

Schlops
Posts: 20
Joined: Wed Oct 16, 2002 2:29 pm

Postby Schlops » Tue Nov 26, 2002 10:35 pm

I have the same problem :( I don't think it has to do anything with paths, cause every other script runs fine. I can only create a mesh consisting of one triangle. I get this error, when I call update()
Stay Rude!

daddy
Posts: 4
Joined: Tue Nov 19, 2002 2:22 am

Postby daddy » Tue Nov 26, 2002 10:52 pm

I did succeed in creating a series of vertexes (I haven't tried making faces yet, at least not that kind) I used the code in S68's post "Add material with 2.25API" posted at 6:08 on Tue November 19th in the Python part of the Elysiun forum.

Maybe he has some special magic - he (or she) does not see fit to call update() at all.

Schlops
Posts: 20
Joined: Wed Oct 16, 2002 2:29 pm

Postby Schlops » Tue Nov 26, 2002 11:15 pm

Thanks, I take a look at it. Creating vertices is no problem for me, I created a lot of them. But adding faces...
Stay Rude!

theeth
Posts: 1184
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Postby theeth » Wed Nov 27, 2002 3:35 am

daddy wrote:Maybe he has some special magic - he (or she) does not see fit to call update() at all.

as far as I understood it, the update() method should only be called when creating ngons.

here's a little example that creates a plane, inspired by the docstring of the Mesh module (always read the docstrings, they are your best friends)

Code: Select all

import Blender

vlist = []

mesh = Blender.Mesh.New()

vlist.append(mesh.addVert((1.0,1.0,1.0)))
vlist.append(mesh.addVert((-1.0,1.0,1.0)))
vlist.append(mesh.addVert((-1.0,-1.0,-1.0)))
vlist.append(mesh.addVert((1.0,-1.0,-1.0)))

mesh.addFace(vlist)

ob = Blender.Object.New("Mesh")
ob.link(mesh)

Blender.Scene.getCurrent().link(ob)


I hope that's more clear.

Martin
Life is what happens to you when you're busy making other plans.
- John Lennon

Schlops
Posts: 20
Joined: Wed Oct 16, 2002 2:29 pm

Postby Schlops » Wed Nov 27, 2002 5:40 pm

Well, works fine for one face, but try adding more faces. :?
It seems as Object.link() calls Mesh.update() => Boing :evil:
Must be a bug
Stay Rude!

theeth
Posts: 1184
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Postby theeth » Wed Nov 27, 2002 8:35 pm

you have to use a different list for each face (at list, that's how I understood it)

like this:

Code: Select all

import Blender

face1 = []

mesh = Blender.Mesh.New()

face1.append(mesh.addVert((1.0,1.0,1.0)))
face1.append(mesh.addVert((-1.0,1.0,1.0)))
face1.append(mesh.addVert((-1.0,-1.0,-1.0)))
face1.append(mesh.addVert((1.0,-1.0,-1.0)))

mesh.addFace(face1)

face2 = []
face2.append(face1[0])
face2.append(face1[1])

face2.append(mesh.addVert((-1.0,2.0,1.0)))
face2.append(mesh.addVert((1.0,2.0,1.0)))

mesh.addFace(face2)

ob = Blender.Object.New("Mesh")
ob.link(mesh)

Blender.Scene.getCurrent().link(ob)



Martin
Life is what happens to you when you're busy making other plans.

- John Lennon

Schlops
Posts: 20
Joined: Wed Oct 16, 2002 2:29 pm

Postby Schlops » Fri Nov 29, 2002 1:03 pm

D'oh, I always used the first list (removed the unwanted vertices first) for each new face. But this seems a lot easier. I will give it a try, thanks theeth!
Stay Rude!


Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests