Set 3D Instance Matrix¶
Set 3D Instance Matrix¶
1# This example sets a matrix (Scaled by a 3D vector) to all the 3D instances 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 translation 3D vector
7vector = three_d.vector3_d(2, 1, 1)
8
9# Create a local variable for the output toolbox
10ot = impact.gui.output_toolbox
11
12for layer in impact.active_drawing.layers:
13 if layer.layer_type == "THREE_D":
14 scene = layer.scene
15
16 if not scene.isNone():
17 for instance in scene.instances:
18 if not instance.isNone():
19 m = instance.matrix()
20
21 # Scale the matrix by a 3D vector
22 m.scale(vector)
23
24 # Sets the matrix
25 instance.matrix = m
26
27 else:
28 ot.add("No 3D scene")
29
30 else:
31 ot.add("No 3D Layer")
32