blob: 4131210e9023de1f3352922721e5c2fe1a03ca28 (
plain)
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
|
'''
To load stuff that assumes a Blender scene is already loaded
I need to wait for the BLEND file of the template to load and
then add the functions and stuff I want after said file loads.
The use of "bpy.app.handlers" and "persistent" help in this case
for some reason I don't undertand yet >:] (but meh, it works)
References:
https://s-nako.work/2020/09/blender-error-attributeerror-_restrictcontext-object-has-no-attribute-view_layer/
https://web.archive.org/web/20210925181415/https://blenderbrew.com/custom-application-templates-in-blender/
'''
import bpy
from bpy.app.handlers import persistent
#######################################################
# define function that sets all the blenxy stuff:
# galaxy unit, custom collada exporter/importer
# custom CSV animation file (for BCK) exporter/importer
#######################################################
@persistent
def set_blenxy_env(dummy): # "dummy" is a variable that is somehow
# passed to set_blenxy_env when called by
# bpy.app.handlers.load_post.append
from . import blenxy_settings_stuff # settings blenxy has
from . import collada_bmd_bdl_export # custom exporter for DAE files
from . import collada_bmd_bdl_import # custom importer for DAE files
from . import csv_anim_bck_export # exporter for CSV files for BCK conversion
from . import csv_anim_bck_import # importer for CSV files from BCK animation
# more scripts can be added here
#############################
# register/unregister stuff
# for set_blenxy_env function
#############################
def register():
print("\nWelcome to Blenxy!\n")
print("Setting Blenxy Environment...\n")
bpy.app.handlers.load_post.append(set_blenxy_env)
def unregister():
print("\nSee you later!\n")
bpy.app.handlers.load_post.remove(set_blenxy_env)
if __name__ == "__main__":
register()
|