Question

I'm writing an exporter for Blender, and I ran into a small problem - when I export the same model multiple time, the mesh that gets exported is always assigned a different name ( a numeral prefix is added ).

This is the code I use to access the mesh I want to export:

for ob in bpy.scene.objects:

    # get derived objects
    free, derived = create_derived_objects(scene, ob)

    if derived is None:
        continue

    for obDerived, mat in derived:
        if ob.type not in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META'}:
            continue

        try:
            derivedBlenderMesh = obDerived.to_mesh( scene, True, 'PREVIEW' )
        except:
            derivedBlenderMesh = None

        if derivedBlenderMesh:
                        # ... and the export stuff goes here

    # once everything's done, I remove the created instance
    if free:
        free_derived_objects(derivedBlenderMesh)

I took it from the 3ds exporter to be honest.

I notice that it creates a new (derived ) object and then creates a new mesh ( transformed and everything ), so I guess those are potential places where the new name is assigned.

I browsed through the documentation, but I saw no clear relation between an Object and a Mesh instance other than through the to_mesh method, that obviously creates a new mesh instance.

However - I really need to get the original name. Can someone tell me how to access it?

Thanks in advance :) Paksas

Was it helpful?

Solution

Ok - I went around id ( kinda ). I'm basically ignoring the mesh name, and naming the exported mesh after the object it's embedded in.

This of course works under an assumption, that each and every object HAS A DEDICATED MESH, but I'm duplicating them before the export, so that indeed is the case.

If anyone has a better solution, please post it here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top