forked from ubisoft/mixer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_blenddata_ids.py
112 lines (99 loc) · 2.75 KB
/
test_blenddata_ids.py
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
105
106
107
108
109
110
111
112
import unittest
from tests.blender.blender_testcase import TestGenericJoinBefore
class TestMetaBall(TestGenericJoinBefore):
def test_bpy_data_new(self):
create_metaball = f"""
import bpy
name = "mb1"
mb = bpy.data.metaballs.new(name)
e1 = mb.elements.new(type="CAPSULE")
e1.co = (1, 1, 1)
e1.radius=3
e2 = mb.elements.new(type="BALL")
e2.co = (-1, -1, -1)
obj = bpy.data.objects.new(name, mb)
bpy.data.scenes[0].collection.objects.link(obj)
e2.type = "PLANE"
"""
self.send_string(create_metaball)
self.end_test()
def test_bpy_ops_object_add(self):
action = f"""
import bpy
bpy.ops.object.metaball_add(type='PLANE', location=(1.0, 1.0, 1.0))
o1 = bpy.context.active_object
bpy.ops.object.metaball_add(type='CAPSULE', location=(0.0, 0.0, 0.0))
bpy.ops.object.metaball_add(type='BALL', location=(-1.0, -1.0, -1.0))
"""
self.send_string(action)
self.end_test()
def test_add_remove(self):
action = f"""
import bpy
bpy.ops.object.metaball_add(type='CAPSULE', location=(0.0, 0.0, 0.0))
bpy.ops.object.metaball_add(type='PLANE', location=(1.0, 1.0, 1.0))
bpy.ops.object.metaball_add(type='BALL', location=(-1.0, -1.0, -1.0))
"""
self.send_string(action)
action = f"""
name = "Mball.001"
import bpy
D=bpy.data
D.objects.remove(D.objects[name])
D.metaballs.remove(D.metaballs[name])
"""
self.send_string(action)
self.end_test()
class TestLight(TestGenericJoinBefore):
def test_bpy_ops_object_add(self):
action = f"""
import bpy
bpy.ops.object.light_add(type='POINT', location=(0.0, 0.0, 0.0))
bpy.ops.object.light_add(type='SUN', location=(2.0, 0.0, 0.0))
bpy.ops.object.light_add(type='AREA', location=(4.0, 0.0, 0.0))
"""
self.send_string(action)
self.end_test()
def test_change_area_attrs(self):
action = f"""
import bpy
bpy.ops.object.light_add(type='AREA', location=(4.0, 0.0, 0.0))
"""
self.send_string(action)
action = f"""
import bpy
D=bpy.data
area = D.lights["Area"]
area.size = 5
area.shape = 'DISK'
"""
self.send_string(action)
self.end_test()
def test_morph_light(self):
action = f"""
import bpy
bpy.ops.object.light_add(type='AREA', location=(4.0, 0.0, 0.0))
"""
self.send_string(action)
action = f"""
import bpy
D=bpy.data
light = D.lights["Area"]
light.type = "SUN"
"""
self.send_string(action)
self.end_test()
class TestScene(TestGenericJoinBefore):
def test_bpy_ops_scene_new(self):
action = """
import bpy
scene = bpy.ops.scene_new(type="NEW")
print(scene)
print(f"new scene is {scene}")
scene.unit_settings.system = "IMPERIAL"
scene.use_gravity = True
"""
self.send_string(action)
self.end_test()
if __name__ == "__main__":
unittest.main()