Transform a 3D instance¶
Transform a 3D instance¶
1# This example translates all the 3D instances present in each 3D layer in the active drawing
2
3# Create a local variable for the impact.creator ThreeD object
4three_d = impact.creator.three_d()
5
6# Create a local variable for the output toolbox
7ot = impact.gui.output_toolbox
8
9for layer in impact.active_drawing.layers:
10 if layer.layer_type == "THREE_D":
11 scene = layer.scene
12
13 if scene is not None:
14
15 # create a default 3D matrix
16 matrix = three_d.matrix3_d()
17
18 # create a position 3D vector
19 pos = three_d.vector3_d(10, 20, 30)
20
21 # Translate the matrix by created position vector
22 call(matrix.translate(pos))
23
24 for instance in scene.instances:
25 if instance is not None:
26
27 # Transform the instance
28 call(instance.transform(matrix))
29
30 else:
31 ot.add("No 3d scene")
32
33