More python trouble...

(LethalSideP) #1

This is quite a habit of mine, isn’t it? Getting into python problems, I mean :wink:

Anyway, here’s my latest dilemma. I’ve been generating objects using the putraw function (remember all the fun i had trying to alt-d with the python interface?). Anyway, now that I’ve generated them, I want to animate them. The problem is that I can’t add animation points with the curve.append until there’s an IPO block attatched to the object. Now, each of my objects to be generated needs different animation parameters.

So, in short, how do I create a new IPO block for an object I’ve just created?

Another small question. How do I assign materials to objects via the python API? Generating new ones could be handy, but just assigning pre-existing ones will do for now…

So, any suggestions, anyone? I assure you all that the resulting script should be pretty good…

Thanks for any replies in advance.

(eeshlo) #2

You can’t create new IPO’s (unless you use Publisher, Ipo.New()). Material assignment is also pretty much undo-able. The only way to do this, is by assigning the material name to the mesh.mats list. Creating the mesh, see that it isn’t there, delete the mesh (manually), and create the mesh again, to see the material magically appear…
In Publisher there is the setMaterials() function.

(LethalSideP) #3

BUGGER IT!!! :X :frowning:

I’m very unhappy now. Blender went bust just as I was about to buy a Publisher licence, and now this. I’d been working on this script idea of mine for ages - basically as mass moving duplivert creator. People could’ve used it to create crowds of just about anything - bullets in a bullet-time style thing, planes/fighter craft in animations, crowds of soldiers rushing down hills, swarms of lasers in futuristic dogfights…and now this. I had the GUI finished and everything.


/me goes off muttering about blackmail, and several swearwords followed by API…

WAIT A MOMENT…if that’s the case, then how’s Dynamica creating moving particles? First it has to generate new objects, then assign IPOs to them, so how’s it doing that? Don’t tell me that’s limited to Blender V>2.24 as well, is it? If it is, then I’ll really flip. Anyone?

Seriously, I do need an answer here before I lose my wits. Can someone help me?


(Losing more faith by the minute…)

(eeshlo) #4

No, you don’t need Publisher for Dynamica, there are other ways to do what you want. Particles in Dynamica are just mesh vertices and the mesh is recalculated every frame, that is all, no Ipo’s needed. Material’s however are another story…

(theeth) #5

acutally, I think I found a way around the material bug. I need to test it more, but it seems to work. Basicly, if you add the material name in the Mats field of an NMesh object, it doesn’t show until you refresh the scene. That means, either by rendering, or like you were doing before, deleting it and redoing it. Actually, I think it works better if the object already exists.


(LethalSideP) #6

Hmmm…Thanx for the tip Eeshlo, that’s something I hadn’t thought of. Pretty nice…I think I’ll have to give that a try… And I did notice that material thing when I first tried getting around this problem (ie. before I came crying to you guys), but I couldn’t manage to refresh it through python. Like I’ve said before, i can only teach myself so much… Thanx for the tips!

And sorry if I seemed a bit grumpy. I was revising for 3 exams, and figured I’d go Blendering to clear my head. As you saw, it didn’t really work :wink:

Oh well. /me is off to program with a clearer head than before


(eeshlo) #7

I know it does work if the mesh already exists yes, but like I said not for a new mesh that didn’t exist before. That only works when you create it for the second time, after that assigning new materials is not a problem.