I have a script that’s exporting out a Blender object’s vertex, face, normal, and UV information. I am attempting to convert from NMesh to Mesh. I’ve actually got it to work, however I can’t seem to get the subsurf modifier to be applied correctly in the export of the data. It’s previous way of doing this was:
When I use this, the subsurf modifier is applied, but via the subsurf’s levels rather than the render levels. And right as I export, the object subsurf’s again. And if I remove the subsurf modifier, it goes back one subsurface level put not to the original object (so I guess I am applying a subsurface level somehow). I’m hoping that the getFromObject is the key, but it’s implementation is what I’m not getting. Without getFromObject, no subsurf gets applied (since it doesn’t access the modifier). The api doc say that it should have two int values, but when I use two I get errors.
Any help/ideas would be appreciated.
I don’t know if that’s the best way to do it. The first line will get the mesh reference from the obj and the second then copies the mesh plus applied modifiers back into that reference (this may be why you are seeing the subsurf being applied). Try using:
I think I’m beginning to understand, but I’m still just shooting at the dark. I’ve got it to get the right subsurf, but now the object is in the wrong orientation when rendering to the outside renderer or just not looking right.
Here is what I’ve used that outputs the object in the wrong orientation:
I think the matrix was the issue unless I was doing something stupid before.
Anyways, now the question is if creating a new mesh and using transform to export the vertex data has any consequences to the .blend size or script performance. I recall the transform example in the api savign then restoring vertices. Nor am I deleting any vertices (as per Cam’s suggestion).
I noticed that the subsurf data being exported is from the “levels” and not the “render levels.” The API says getFromObject(object, cage=0, render=0), with render determinng whether the render setting for modifiers will be used or not. The problem is when I try to use the second int (as in getFromObject(object, 0, 1) , I get an error (TypeError: Expected object or string and optional integer arguments). Is the second int for render not available in Blender 2.43?
Thanks for the tip on using the object rather than the name.
I also went to Mesh.c to figure out what the deal was, but it definitely doesn’t seem to work. If anyone care’s to have a look at it - (cough ideasman cough) - You can find the script here:
Yeah, I’m using 2.43 and Python 2.4.4. Thanks for showing that you can get it to work. I’m still having no luck with getting the render int recognized, so I’ll keep trying to figure out what the deal is as it seems to be on my end.
Your example doesn’t work for me (I get the same error about the need for a string and two ints), but it works when it’s (ob, 0). And now that it works for you in the Sunflow script I posted, I’m even more perplexed. Did you use the code right in the script and just added the ,1 to the getFromObject?
yep, just added a 1 to getFromObject, to read me.getFromObject(ob, 0, 1)
strange it wont work since I dont think this has been touched since 2.43
can you double check your running 2.43, or get a recent build from graphicall
Sorry I relay dont mean to sound patronizing but this has been in for a while and works for me, the only thing I can think of that would cause this problem is that your running an older version of blender.
No worries about being patronizing. I could be missing something that’s right under my nose, so I’m glad to go through all options.
I just downloaded the default windows build from b.org and I downloaded the glass theme .exe from graphicall. The b.org version still doesn’t work, but the cvs build from graphicall does work. The only difference I see is that the two builds that don’t work have command windows that say compiled with Python 2.4 and are built with 2.43 source and the build that does work specifies that it’s compiled with Python 2.4.4 and is a cvs build.