[Bf-python] Re: Your obj importer

Campbell Barton cbarton at metavr.com
Sun Jun 6 05:12:38 CEST 2004


Hi, Im clearing some bugs in the OBJ importer.

Mainly the material one (I think its a blender bug.)
Check thios out..

    def applyMat(mesh, f, mat):
        if mat not in mesh.materials:
          mesh.addMaterial(mat)
        f.mat = mesh.materials.index(mat)
        return mesh, f

Some how this stuffs up and It thinks the material is not there and 
raises an error:
You alredy have this mat applied to the mesh.

This works.

    def applyMat(mesh, f, mat):
       
       
        mIdx = 0
        for m in mesh.materials:
            if m.getName() == mat.getName():
                break
            mIdx+=1
       
       
        if mIdx == len(mesh.materials):
          mesh.addMaterial(mat)
       
        f.mat = mIdx
        return mesh, f

There was a problem importing faces > v verts, So im fixing that now.

- Cam





Willian Padovani Germano wrote:

>Hi Campbell,
>
>Just a note: I was looking at your script now and saw that you wrote functions
>to strip the path from a filename.  Blender.sys has functions to handle this.
>
>About the license, please take a look at files in the scripts dir for examples.
>You can use GPL, BAL (Blender artistic license) or BSD, public domain note
>("this script is in the public domain"), whatever.  It just has to be
>"friendly", meaning it allows users to use the script just as they can use the
>rest of Blender.
>
>--
>Willian, wgermano at ig.com.br
>
>
>
>  
>


-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241




More information about the Bf-python mailing list