Previous Thread  Next Thread

chat icon Mesh creation in Python with 2.25

daddy

Posted: Tue Nov 19, 2002 2:31 am
Joined: 19 Nov 2002
Posts: 4
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 ?
Reply with quote


jms

Posted: Tue Nov 19, 2002 11:53 am
Joined: 19 Oct 2002
Posts: 327
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.
Reply with quote


daddy

Posted: Tue Nov 19, 2002 4:14 pm
Joined: 19 Nov 2002
Posts: 4
I was using windows NT4. I will try it on Suse Linux 7.2 when I get home.

Many thanks
Reply with quote


daddy

Posted: Wed Nov 20, 2002 3:28 am
Joined: 19 Nov 2002
Posts: 4
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 ?
Reply with quote


Schlops

Posted: Tue Nov 26, 2002 10:35 pm
Joined: 16 Oct 2002
Posts: 20
I have the same problem Sad 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!
Reply with quote


daddy

Posted: Tue Nov 26, 2002 10:52 pm
Joined: 19 Nov 2002
Posts: 4
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.
Reply with quote


Schlops

Posted: Tue Nov 26, 2002 11:15 pm
Joined: 16 Oct 2002
Posts: 20
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!
Reply with quote


theeth

Posted: Wed Nov 27, 2002 3:35 am
Joined: 16 Oct 2002
Posts: 1177
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:

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
Reply with quote


Schlops

Posted: Wed Nov 27, 2002 5:40 pm
Joined: 16 Oct 2002
Posts: 20
Well, works fine for one face, but try adding more faces. Confused
It seems as Object.link() calls Mesh.update() => Boing Evil or Very Mad
Must be a bug
_________________
Stay Rude!
Reply with quote


theeth

Posted: Wed Nov 27, 2002 8:35 pm
Joined: 16 Oct 2002
Posts: 1177
you have to use a different list for each face (at list, that's how I understood it)

like this:

Code:

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
Reply with quote


Schlops

Posted: Fri Nov 29, 2002 1:03 pm
Joined: 16 Oct 2002
Posts: 20
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!
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group