I've written a python batching function that runs though a list of OBJ files. It imports the OBJ, adds some modifiers, then saves. I want to know the statistics at the start and at the end. However, I get the same statistics at the end.
My code looks basically like this:
ImportOBJ(filename)
stats_start = bpy.context.scene.statistics(bpy.context.view_layer)
obj.modifiers.new('DecimateHalf', 'DECIMATE')
obj.modifiers['DecimateHalf'].ratio = 0.5
stats_end = bpy.context.scene.statistics(bpy.context.view_layer)
However, the output is the same.
stats_start: 'Collection | objfile | Verts:76,419 | Faces:113,902 | Tris:113,902 | Objects:1/1 | Memory: 54.6 MiB | 2.90.1'
stats_end: 'Collection | objfile | Verts:76,419 | Faces:113,902 | Tris:113,902 | Objects:1/1 | Memory: 54.6 MiB | 2.90.1'
I can get the same result with the Python Console by copy pasting these lines so they execute together.
bpy.context.scene.statistics(bpy.context.view_layer)
C.object.modifiers.new('DecimateHalf', 'DECIMATE')
C.object.modifiers['DecimateHalf'].ratio = 0.5
bpy.context.scene.statistics(bpy.context.view_layer)
Which does the same thing, output looks like this:
>>> bpy.context.scene.statistics(bpy.context.view_layer)
'Collection | objfile | Verts:76,419 | Faces:113,902 | Tris:113,902 | Objects:1/1 | Memory: 51.4 MiB | 2.90.1'
>>> C.object.modifiers.new('DecimateHalf', 'DECIMATE')
bpy.data.objects['objfile'].modifiers["DecimateHalf"]
>>> C.object.modifiers['DecimateHalf'].ratio = 0.5
>>> bpy.context.scene.statistics(bpy.context.view_layer)
'Collection | objfile | Verts:76,419 | Faces:113,902 | Tris:113,902 | Objects:1/1 | Memory: 54.6 MiB | 2.90.1'
I've tried updating the layer using bpy.context.view_layer.update()
but it doesn't work. Please note that I don't want to apply the modifier, as I would like to keep the original import.