1
$\begingroup$

From the default startup, if you run bpy.context.scene.copy() you get a copy of your scene that has 0 user and gets added to the orphan data.

In reality, if you save and revert the file, your scene will still be there, even though any other orphan data would get removed if you did that. However, for the users of my add-on, seeing an orphan scene would be confusing and worrying.

I could add a fake user but I find it unsatisfactory and still confusing, as you may wonder what would happen when trying to delete the scene, not to mention the unnecessary "F" in the scene's name.

So how can I make that scene not orphan without adding a fake user?

So far the only hacky workaround I found is to run some operator and then run the undo operator, which I assume does the trick because it reloads many components of the file including the scene's user (whatever it is), but of course this is far from an ideal solution.

$\endgroup$
2
  • $\begingroup$ As with all ID objects ob.use_fake_user = True prevents a zero user count. $\endgroup$
    – batFINGER
    Jun 11, 2020 at 18:45
  • $\begingroup$ Sorry, when editing my post I accidentally deleted the line where I talk about not using a fake user, silly me! It's back now. $\endgroup$ Jun 11, 2020 at 19:03

1 Answer 1

2
$\begingroup$

Use the operator

For the time being whilst using Scene.copy() produces a zero user scene, using the operator instead, does not

bpy.ops.scene.new(type='FULL_COPY')

A new scene created via newscene = scene.copy() does not pick up the window using it (as a user) when context.window.scene = newscene nor does the one being unset lose a user. I imagine this will be fixed sometime soon.

$\endgroup$
1
  • $\begingroup$ Thanks. I cannot use the operator for several reasons (performance, context and naming issues). Using copy() is way simpler and faster so I'll just leave the scenes with zero user and give a warning that this doesn't mean the scene will be deleted. I hope this will get fixed. Should I make a report on developer.blender.org? $\endgroup$ Jun 12, 2020 at 9:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .