breakin wrote:myObject=Blender.Object.Get('myObjectName')
myObject.setName('myNewObjectName') # line 4
fails (blender 2.28a, rh9) with the following error:
Traceback (most recent call last):
File "Text.001", line 4, in ?
AttributeError: expected a String as argument
It appears to be broken. ( or maybe the interpreter just didn't like the name you chose. heehee )
The Object.setName() method is calling PyArg_Parse() rather than PyArg_ParseTuple() to get its arguments. PyArg_Parse is an older func, maybe left over from an earlier implementation.
Under NVerts you state that the normal shoudl be obtained using
vert.no.nx but it should be vert.no.x. Types for uvco is omitted. Suppose all of this will be clarified over time during the iterative documentation process :)
import Blender
# get the current scene
scene = Blender.Scene.getCurrent()
# loop over all objects in the scene
children = scene.getChildren()
print "%s children" % len(children)
for child in children:
print child
# which type?
type = child.getType()
if type == "Mesh":
# mesh
print "I'm a mesh"
data = child.getData()
print data
print dir(data)
print "name: %s" % data.name
print "verts: %s" % len(data.verts)
for vertex in data.verts:
print "%s: %s" % (len(vertex.loc), vertex.loc)
print "faces: %s" % len(data.faces)
for face in data.faces:
vertices = face.v
print "face: [",
for vertex in vertices:
print vertex.index,
print "]"
else:
print "type: %s ..." % type
print "... not handled (yet)"
First of all: Thanks that someone took care about the Python API !!!
Hi,
actually, my name is Michel
Luckily I'm not the only one who's actively working on the Python API; many others are jumping in!
About the bug report with regards to argument parsing: This is fixed in cvs now. Apparently some more issues where in the code. I have not tested these functions very well
Thanks for reporting this!!!
With regards,
Michel
You can have one of two things: Progress or Progress Reports.
Tell us what version of blender and show us a code snippet.
I use blender 2.28 and I'm not sure about this cause I'm not realy using
Image.Load .
When I make an object let's say a machine gun I use that
Add material and add texture from the buttons window and not telling
blender through phyton that I wanna have the image from this path
Even with my psychotic powers, I can't tell what is going on without seeing some code. However, this snippet prints the filenames of Image blocks that were created for image textures via the buttons:
stiv wrote:Even with my psychotic powers, I can't tell what is going on without seeing some code. However, this snippet prints the filenames of Image blocks that were created for image textures via the buttons:
print faces[0].image // result is [none]
And that's the problem. I wanna loop through all selected objecs and
get those image objects so I could know which face uses which image.
How can I use opengl on it when I don't know what texture file they use.
Aha! I think I see the problem. Question: Do your mesh faces have a UV texture?
Images can be used as Textures in a Material block, rather like glueing the image on the whole object. Images can also be used for UV Textures. This is like cutting the image up and applying it to individual mesh faces.
Your code looks ok. ( you may want to use face[0].image.getFilename() to get the complete path ).
From the recent bpython doc for NMesh.NMFace:
Warning: Assigning uv textures to mesh faces in Blender works like this:
Select your mesh.
Enter face select mode (press f) and select at least some face(s).
In the UV/Image Editor window, load / select an image.
Play in both windows (better split the screen to see both at the same time) until the uv coordinates are where you want them. Hint: in the 3d window, the 'u' key opens a menu of default uv choices and the 'r' key lets you rotate the uv coords.
Leave face select mode (press f).