The image above show the structure of the batch widget execution events. Below there are some description of each level.

Start Event: The first place the commands will run for every batch widget. You can use this level to run commands like, for example, file new, set project, set global variables, etc…
Input: SceneInfo

Scene Level Event: Here is where the commands will execute your scene events, its should be a clenup command like “Optimize Scene Size” for example, that commands don’t need to know about the references or objects.
Input: SceneInfo

Reference Type Level Event: In this level you can run commands that are related to the reference types(PROP, SCENARIO, CAMERA, CHARACTER, VEHICLE, etc). You can group all references of each type for example, or run a specific command for references of type SCENARIO for exemple.
Input: ReferenceType

Reference Level Event: Here we can run commands for each reference in the scene. You can do a lot of things in the section. Run per object commands, load/remove references, apply shaders, export caches, etc…
Input: SceneInfo, ReferenceType, ReferenceName, isCamera

End Event: In this level you can run the final commands like save the scene.
Input: SceneInfo

The code below shows a template for start creating a new batch widget. The level events described above are highlighted.
To create a new one you will need to replace all “WidgetName” word to your batch widget name and fill the WIDGET_NAME, WIDGET_TYPE, WIDGET_DESC, WIDGET_SETTINGS variables. And save that in the “Widgets” folder replacing the file name from “WidgetName.py” to “YourWidgetName_widget.py”. It will apear on the batch widget library on the ui.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#===============================================================================
# #Autor: Rosenio Pinto
# #e-mail: kenio3d@gmail.com
# #
# # This is the template for create custom batch widgets
# #
#===============================================================================
from BatchWidgetEngine import *

WIDGET_NAME     = 'WIDGET NAME'
WIDGET_TYPE     = 'WIDGET_TYPE'
WIDGET_DESC     = 'WIDGET DESCRIPTION.'
WIDGET_SETTINGS = {}

class WidgetName_widget(BatchWidgetEngine):
    name        = "WidgetName"
   
    def __init__(self, scene_info={}):
        super(WidgetName_widget, self).__init__(scene_info)
       
        self.reference_type_level_on = False
        self.reference_level_on      = True
       
        self.onStart(self.scene_info)
       
    #===========================================================================
    # #The starter function
    #===========================================================================
    def onStart(self, scene_info):
       
        #===================================================================
        # #On Start level event commands here
        #===================================================================
        # 'CODE HERE'
        #===================================================================
        # #On Start level event commands here
        #===================================================================
       
        return self.run()
   
    #===========================================================================
    # #Run on the scene
    #===========================================================================
    def scene_level_event(self, scene_info):
        '''Scene level event'''

        #===================================================================
        # #Scene level event commands here
        #===================================================================
        # 'CODE HERE'
        #===================================================================
        # #Scene level event commands here
        #===================================================================

    #===========================================================================
    # #Run for each reference type
    #===========================================================================
    def reference_type_level_event(self, reference_type):
        '''Reference type event'''
       
        #===================================================================
        # #Reference type level event commands here
        #===================================================================
        # 'CODE HERE'
        #===================================================================
        # #Reference type level event commands here
        #===================================================================

    #===========================================================================
    # #Run for each reference
    #===========================================================================
    def reference_level_event(self, scene_info, reference_type, reference_name, isCamera):
        '''Reference level event'''
       
        #===================================================================
        # #Reference level event commands here
        #===================================================================
        # 'CODE HERE'
        #===================================================================
        # #Reference level event commands here
        #===================================================================

    #===========================================================================
    # #Last function called
    #===========================================================================
    def onEnd(self, scene_info):
       
        #===================================================================
        # #On end level event commands here
        #===================================================================
        # 'CODE HERE'
        #===================================================================
        # #On end level event commands here
        #===================================================================
       
        return scene_info
   
   
   
#===============================================================================
# # The function that returns the class from external tools
#===============================================================================
def main(sceneInfo={}):
    return WidgetName_widget(sceneInfo)

Note that below highlighted lines refer to the ReferenceTypeLevel and the ReferenceLevel event. If it is set to “False” the engine will ignore that execution level. It is util for otimizations like if you want only run commands on Start/End level or SceneEvent level and ignore the references iteration.

1
2
3
4
5
6
7
    def __init__(self, scene_info={}):
        super(WidgetName_widget, self).__init__(scene_info)
       
        self.reference_type_level_on = False
        self.reference_level_on      = True
       
        self.onStart(self.scene_info)