Either I’m being seriously pranked or this is the utter most bullshit error any software can have.

Layer 1: object with python controller, scene.addObject(‘obj1’, own, 0)
Layer 2 (inactive): obj1

result: ValueError: scene.addObject(object, other, time): KX_Scene (first argument): object must be in an inactive layer

So, I go to layer 2 and create a cube, I return to layer 1 (leaving layer 2 inactive), edit the script so it reads: scene.addObject(‘cube’, own, 0)

result: works perfectly

I change it back to scene.addObject(‘obj1’, own, 0)

result: ValueError: scene.addObject(object, other, time): KX_Scene (first argument): obj
ect must be in an inactive layer

What the serious fuck is going on?

Uploading a blend file for us to examine would be helpful.

Please, try to refrain from profanity here, it’s a forum rule.

Without your file, it’s difficult to say what is going wrong. However, it might be that you’re trying to add an object in a different scene, which although valid, does throw this error. You can work around it by referencing the object from the scene’s inactive objects list.

The object is in the same scene, a single armature modifier (armature is in layer 1 which is active but I also tried to put the armature in other layer with the same result).
The object that needs to be added is in every aspect exactly like a newly created cube.
Its in the same scene as the cube, in the same layer as the cube.
Uploading the blend file is not an option at this point; I would have to make a new one just to give an example and who knows if it’ll happen the same

We usually advise creating a small, simple demonstration of the issue. This quickly helps you to identify if it is something you’re doing wrong, and if not immediately obvious, allows us to quickly reproduce the issue.

For some reason the objects that need to be added are not in current_scene.objectsInactive and I hve absolutely no idea why

I tried making a new blend file just to address the issue.I only get the error when I attempt to add the human model, not a cube, not a circle, not a cone, just the human model.

There you go:

Use the property ‘a’ in the cube on layer 1 to attempt to add the human model or another cube

Apparently it has something to do with the armature being parented to the cube in layer one

Cow Droppings!

For future reference, you can upload files in your post, which saves the hassle of going through download sites :slight_smile:

Also, don’t call scripts “test.py”, as it shadows the test module in the Python standard library, so it often fails to run on some computers.

If you write “print(own.children)” in your module, you’ll notice that the cube has a child object. This child (the armature) is in the active layer, hence the script throws an error. I’m not sure why you’re doing that, but the error is to be expected.

I had similar problem with my BGMC script for doors. It was different, of course, but it appears so latest blender has some problems out there with stuff like that…

Imagine I have a gazillion models that use the same armature, it’ll be less than ideal to have them all hidden in an active layer. Instead, my idea is to have them in an inactive layer and add them as needed.

cube layer 2,

Grab the cube from where it is, and grab it from the inactive layer

obj = scene.objectsInactive['cube']
scene.addObject(obj, own, 0)

That should work

It’s better to use a dummy mesh patented to your armature and the use switch mesh. Adding an object which has children to a scene also adds the children. This can cause problems elsewhere too.

Be aware, objects whose parent can’t be created will not be created either.

This means:

  • do not parent at unsupported objects such as curves, metaballs …
  • do not parent an active object against an inactive object
  • do not parent an inactive object against an active object
1 Like

Ok, I think I’ll just take the healthier approach and use replace mesh, I just hope the armature works for meshes with different weight painting when replaced.
Thanks everyone for the help.

Well, I forgot to tell you: if you wanna spawn armature, parent it to empty and spawn empty.

P.S. Haven’t read anything posted except his answer to me and his topic strart :smiley:

Actually that is a great idea, thanks adriansnetlis!