Apply_def gives odd mesh when called from script

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
DnasTheGreat
Posts: 0
Joined: Mon Jun 05, 2006 2:57 pm

Apply_def gives odd mesh when called from script

Post by DnasTheGreat » Thu Jun 08, 2006 2:14 am

Hey,

I'm writing an importer for a model format that a game I'm doing art for uses... the format is kind of weird, so, at some point I have to apply the deformations some bones made (and then move the bones around again) otherwise it acts really strange when editting.

When I run the mesh importing code and tehn manually run the Apply_defs script, everything works wonderfully.

However, when I run Apply_defs in the other script using Blender.Run() things act very strange.

The new object (Apply_defs makes a new object and selects it... and I delete the old one) at first shows double the number of vertices and faces, does not show its name in the corner as being selected, cannot go into Edit Mode, and shows up as simply a dot (its center). Right-clicking someone outside fixes the numbers, increases the memory usage by about 100k, the object's name still does not show up as being selected nor does it show up as anything.

Right-clicking where the dot is finally shows it's name on the selected object thing and allows Edit Mode. Looking into Edit Mode, it seems that the script sets every vertex to be at (0,0,0). Applying the old (still deformed) armature to the new mesh confirms this.

I could leave a message at the end of the script for the user to run Apply_def and then another script to do the final necesary bone moving around, but... that's just weird. :)

So... any idea what's causing this?

(I have also tried import Apply_def and pasting the relevant bits of code from Apply_def and the same result occurs.)

maciej.krol
Posts: 0
Joined: Tue Jun 27, 2006 2:33 pm

Post by maciej.krol » Tue Jun 27, 2006 4:16 pm

Apply_def.py uses Blender.NMesh.GetRawFromObject which is quite problematic function. Sometimes it returns really weird results. I have found that executing Blender.Redraw() before GetRawFromObject helps.

You can try running Blender.Redraw() before executing Apply_def.py

DnasTheGreat
Posts: 0
Joined: Mon Jun 05, 2006 2:57 pm

Post by DnasTheGreat » Fri Aug 11, 2006 12:50 am

Nope. :( Doesn't work.

Any alternatives to getting the same effect as Apply_def.py? which I see is now renamed to object_apply_def.py.

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

Post by jms » Sat Nov 11, 2006 12:08 pm

DnasTheGreat wrote:Nope. :( Doesn't work.

Any alternatives to getting the same effect as Apply_def.py? which I see is now renamed to object_apply_def.py.
You can try the original script : fixfromeverything
http://jmsoler.free.fr/didacticiel/blen ... retxgroups
(sorry this web page is in french)
Zoo-3D.Blender, Ze French-Speaking Community SKB My french book about Blender.

Post Reply