File size: 1,346 Bytes
e27853f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import bpy
import math
import numpy as np

# a set of helper functions that you can use
# 1) move_to: move the object to location
# 2) move_by: move the object by the vector of change

# DO NOT SURPASS the range for the x, y, z coordinates of all objects:
# x: (0.3 , 3)
# y: (12 ,15)
# z: (0, 3)

def move_to(obj, location):
    """ Set the object location.
    """
    obj.location = location
    bpy.context.view_layer.update()
    return obj
    
def move_by(obj, vector):
    """ Shift the object location by a 3D vector
    """
    obj.location[0] += vector[0]
    obj.location[1] += vector[1]
    obj.location[2] += vector[2]
    bpy.context.view_layer.update()
    return obj

# These are movable objects. 
# with open('log.txt', 'w') as f:
#     f.write(bpy.data.objects)

cabinet = bpy.data.objects['Cabinet']
plant = bpy.data.objects['Plant']
mirror = bpy.data.objects['Mirror']
sink = bpy.data.objects['Sink']
toilet = bpy.data.objects['Toilet']

# These are the current locations of the movable objects
cabinet.location = (2.4661, 14.201, 0.1277)
plant.location = (3.2168, 14.327, 0.57311)
mirror.location = (0.1374, 13.5573, 1.3960)
sink.location = (1.7123, 12.7161, 0.8306)
toilet.location = (1.9395, 14.5101, 0.4867)

# DO NOT SURPASS the range for the x, y, z coordinates of all objects:
# x: (0.3 , 3)
# y: (12 ,15)
# z: (0, 3)