object name

is there a way to set a predefine name for object in following code

mesh1 = NMesh.GetRaw()
vNew1 = NMesh.Vert( x, math.cos( x ), 0 )
mesh1.verts.append( vNew1 )

i tough that “mesh1” was the name for the object but it’s not !


i get the object with a defautl name of “Mesh”

but would like to give it a specific name is this possible and how?

Thanks

There are objects and there are meshes. They each have their own name. A Blender name can only be 21 characters in length (too short in my opinion, but that’s the way it is).

The object defines the LOCROTSCALE of a mesh but it is not the mesh.

I believe NMesh is depreciated, so you probably want to work with Mesh instead.
http://www.zoo-logique.org/3D.Blender/scripts_python/API/Mesh-module.html

In you code, the variable “mesh1” is not the mesh either. It is merely a variable pointing to the mesh. You could have just as easily typed…(to be confusing)


myArmature = NMesh.GetRaw()

This code would not make the NMesh an armature, it simply would be the name your code will reference the NMesh by while it is executing. To set the name of the NMesh, you would use code like this.


mesh1.name  = "mesh1"

but is there a way to give it a name

i guess it’s the last thing you said

to change the name

and ok i should go witht he Mesh isntead of NMesh is that the latest

i come back with the whole little script to do a sin and cos grahp

cause i got another problem with the second mesh
it’s not drawing in blender

not certain why can you help with this one

code ###############

import math
import Blender
from Blender import NMesh
x = -1 * math.pi
mesh = NMesh.GetRaw()
vNew = NMesh.Vert( x, math.sin( x ), 0 )
mesh.verts.append( vNew )
cyclemax=5
x = x * cyclemax
for j in range (1,cyclemax):
while x < math.pi*cyclemax:
x += 0.1
vOld = vNew
vNew = NMesh.Vert( x, math.sin( x ), 0 )
mesh.verts.append( vNew )
mesh.addEdge( vOld, vNew )

NMesh.PutRaw( mesh, “SineWave”, 1 )
Blender.Redraw()

mesh1 = NMesh.GetRaw()
vNew1 = NMesh.Vert( x, math.cos( x ), 0 )
mesh.verts.append( vNew1 )

cyclemax=5
x = x * cyclemax
for j in range (1,cyclemax):
while x < math.pi*cyclemax:
x += 0.1
vOld = vNew1
vNew1 = NMesh.Vert( x, math.cos( x ), 0 )
mesh1.verts.append( vNew1 )
mesh1.addEdge( vOld, vNew1 )

NMesh.PutRaw( mesh1, “cosWave”, 1 )
Blender.Redraw()

###############

Thanks

My guess is you’re just assigning ‘mesh1’ to the same mesh as ‘mesh’–which I would imagine is the active object’s mesh.

Probably need to do mesh1 = NMesh.new or however you create a new mesh, I just made up the .new part.

not certain why i used this Nmesh thin - but that was last year i think !

why would the Old data from the first would influence the new data
unless there is a way to zero the data before using it on the second one but how ?

i tough the mesh was supposed to pass the info to the left side which is a new variable!

but in any case i have to get read of the Nmesh and replace with Mesh i think

so it has to be rewritten i guess
can anyone help with this

Thanks
Happy blendering

Like I was saying I’m just guessing here but…

It seems that when you do ‘mesh = NMesh.GetRaw()’ and ‘mesh1 = NMesh.GetRaw()’ that mesh == mesh1 because you don’t change what NMesh is point to (most likely the active object but that is yet another guess).

The second mesh isn’t drawing because it is equal to the first mesh.

I’m probably wrong but that’s what it looks like from reading the code.

not certain

but i do get another object but it’s empty
the second object has no vertices just the center alone

i’ll try to see if i can make this one work
if not then i’ll used another way

Thanks