How to chain MeshProxy copy with LibNew with multiple LibLoad .blend have same meshes

Hello all,

My aim is to be able to LibLoad different models that share the same mesh name property

Using a generic Python class that contain the constructor init, and then subclass of this which only define where the pathname to .blend


class all:__init__(self):
place where i construct and object with libload model property

class car1(all):
model = 'car1.blend'

class car2(car1):
model = 'car2.blend'

car1.blend and car2.blend have exactly same meshes names because i will reuse the “all” class constructor to add an object according to the model.

So in the constructor, I Libload the model, and then i try to retrieve recently loaded object using the method of scene.objectInactive

Then, for each of these object, i get the meshes property giving me KX_MeshProxy used in this object.
And, i use LibNew to copy mesh returned

Trouble happens here, because LibNew do not seems to accept anything else except list of string of mesh name (should be list of proxy mesh instead)

So when i instanciate car1, i have correct object with correct mesh, and i instanciate car2, but this object continue to use the first time list of mesh instead of new added mesh list.

Is there a way to chain mesh proxy copy with LibNew when I LibLoad multiple .blend that having same meshes names.
Or do I have to name mesh in every models a way that they are unique :confused:

Not sure if I am very clear, but I hope!

Be aware that my Unique Libload will take a lot longer than a libnew -> So you’ll need it to happen at game start in a loading screen.

I already read your solution, in fact i read all topic speaking about Lib* on this forum :slight_smile:
And the main problem will be that unique object will share the same mesh. So if I apply something on one, all gonna be affected.

I suppose you did something wrong because the whole point of this technique is to be able to modify meshes without affecting their copies.

You’re absolutely right… my mistake.
So in fact, i do not need any LibNew to have multiple copy of meshes.
The way sdfgeoff tag inactive object allow to have a unique one each time.

However, don’t your function need a lock/unlock to ensure that there is no messy behaviour, for example, if multiple LibLoad run at the same time?

I’m not exactly sure what you mean to say with the latter, but here’s an example of how it works for me. Do notice that the meshes of cubes ‘Cube0’ and ‘Cube1’ share the same name.

Attachments (221 KB)

What I say is, if you use multiple LibLoad with sync=true at the same time, there is a risk at t time that ObjectInactive are messy between different loads.

Yes, that is a risk. So you have to plan your games loading method around it, ie create a level/game loading system capable of handling it. Ever wonder why games have loading screens? Ever wonder why my larger games had dynamic loading screens befor async loading came around? (Probably not).

What you need is some system that will run this code for a few frames, then some different code, all the while keeping track of everything. You can see one example of this in my massive libload thread. In that example, I use the unique libload eight times over eight frames, as well as libloading a couple other files.

As sdfgeoff is saying, you have to load objects one at a time, so you have control over it. Here’s such loading example.

Edit: I still would advice you to give meshes unique names and use LibNew, just to avoid this kind of complex solutions. But it’s a solution nevertheless.

Attachments (223 KB)

Thx you both of you.

Unfortunately, I can’t use LibNew because it only create KX_MeshProxy with meshes names arguments, and not KX_MeshProxy. So, even with unique mesh name in each model, you can spawn car1 and car2, but not car1 two or multiple times.

So i have to use sdfgeoof LibLoad solution to duplicate, because my aim is:

  • being able to implement addon behaviour with just a drag and drop in a folder before game launch
  • everyone can add an “addon” without having to care if his model mesh names have already been used in core game or other addons

I don’t understand. Sure you can spawn car1 multiple times (and modify separately). That’s the whole point of LibNew.

But all car1 will share the same mesh ref, no?

No, the reference is the new mesh, been created with LibNew. But in order to do that first, you need all loaded meshes to have unique names.

Oh ok this time I got it :slight_smile: So will stay on LibLoad cause i really no need to care about model meshes names.


  • Libload duplicate object (so their meshes too) if you use binarized .blend to have unique Lib: so you can interact on each mesh of object separaterly
  • LibNew duplicate meshes that you use to rebuild an original object: but each .blend need unique mesh name