aboutsummaryrefslogtreecommitdiff
path: root/Blender/bpyCruft/makeplate.py
blob: e710a405b71316d584d6c1e80dea147ed0cf2486 (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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import bpy

holeDepth=5
holeRadius=1.5
basePlateRadius=62.0
basePlateDepth=2.0
bpy.ops.mesh.primitive_cube_add()
gearHole = bpy.context.selected_objects[0]
gearHole.name="GearHole"
bpy.ops.transform.resize(value=(9, 14, holeDepth/2.0))
gearHole.location = (0,0,2)

bpy.ops.mesh.primitive_cube_add()
rightWheel = bpy.context.selected_objects[0]
rightWheel.name="RightWheel"
bpy.ops.transform.resize(value=(14, 4, holeDepth/2.0))
rightWheel.location = (0,49,2)

#bpy.ops.object.select_all(action='DESELECT')
#bpy.context.scene.objects.active = bpy.data.objects['GearHole']

bpy.ops.object.modifier_add(type='BOOLEAN')
bpy.context.object.modifiers["Boolean"].object = gearHole   
bpy.context.object.modifiers["Boolean"].operation = 'UNION'
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
newHoles = bpy.context.selected_objects[0]
newHoles.name="NewHoles"

# reselect the first cylinder and delete it (the only one worked!!!)
bpy.ops.object.select_all(action='DESELECT')
bpy.ops.object.select_pattern(pattern = 'GearHole')
bpy.ops.object.delete()
bpy.ops.object.select_pattern(pattern = 'RightWheel')
bpy.ops.object.delete()


bpy.ops.mesh.primitive_cube_add()
leftWheel = bpy.context.selected_objects[0]
leftWheel.name="LeftWheel"
bpy.ops.transform.resize(value=(14, 4, holeDepth/2.0))
leftWheel.location = (0,-49,2)

bpy.ops.object.modifier_add(type='BOOLEAN')
bpy.context.object.modifiers["Boolean"].object = newHoles   
bpy.context.object.modifiers["Boolean"].operation = 'UNION'
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
newHoles1 = bpy.context.selected_objects[0]
newHoles1.name = "NewHoles1"

bpy.ops.object.select_all(action='SELECT')
bpy.data.objects['NewHoles1'].select_set(state=False)
bpy.ops.object.delete()

bpy.ops.mesh.primitive_cylinder_add(vertices=64, radius=holeRadius, depth=holeDepth, location=(4.5, 20.0, 2.0))
screw1 = bpy.context.selected_objects[0]
screw1.name="Screw1"

bpy.ops.object.modifier_add(type='BOOLEAN')
bpy.context.object.modifiers["Boolean"].object = newHoles1   
bpy.context.object.modifiers["Boolean"].operation = 'UNION'
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
newHoles2 = bpy.context.selected_objects[0]
newHoles2.name = "NewHoles2"

bpy.ops.object.select_all(action='SELECT')
bpy.data.objects['NewHoles2'].select_set(state=False)
bpy.ops.object.delete()


bpy.ops.mesh.primitive_cylinder_add(vertices=64, radius=holeRadius, depth=holeDepth, location=(4.5, 38, 2.0))
screw2 = bpy.context.selected_objects[0]
screw2.name="Screw2"

bpy.ops.object.modifier_add(type='BOOLEAN')
bpy.context.object.modifiers["Boolean"].object = newHoles2   
bpy.context.object.modifiers["Boolean"].operation = 'UNION'
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
newHoles3 = bpy.context.selected_objects[0]
newHoles3.name = "NewHoles3"

bpy.ops.object.select_all(action='SELECT')
bpy.data.objects['NewHoles3'].select_set(state=False)
bpy.ops.object.delete()


bpy.ops.mesh.primitive_cylinder_add(vertices=64, radius=holeRadius, depth=holeDepth, location=(4.5, -20.0, 2.0))
screw3 = bpy.context.selected_objects[0]
screw3.name="Screw3"

bpy.ops.object.modifier_add(type='BOOLEAN')
bpy.context.object.modifiers["Boolean"].object = newHoles3   
bpy.context.object.modifiers["Boolean"].operation = 'UNION'
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
newHoles4 = bpy.context.selected_objects[0]
newHoles4.name = "NewHoles4"

bpy.ops.object.select_all(action='SELECT')
bpy.data.objects['NewHoles4'].select_set(state=False)
bpy.ops.object.delete()

bpy.ops.mesh.primitive_cylinder_add(vertices=64, radius=holeRadius, depth=holeDepth, location=(4.5, -38, 2.0))
screw4 = bpy.context.selected_objects[0]
screw4.name="Screw4"

bpy.ops.object.modifier_add(type='BOOLEAN')
bpy.context.object.modifiers["Boolean"].object = newHoles4
bpy.context.object.modifiers["Boolean"].operation = 'UNION'
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
newHoles5 = bpy.context.selected_objects[0]
newHoles5.name = "NewHoles5"

bpy.ops.object.select_all(action='SELECT')
bpy.data.objects['NewHoles5'].select_set(state=False)
bpy.ops.object.delete()


bpy.ops.mesh.primitive_cylinder_add(vertices=64, radius=holeRadius, depth=holeDepth, location=(-37.5, 0, 2.0))
screw5 = bpy.context.selected_objects[0]
screw5.name="Screw5"

bpy.ops.object.modifier_add(type='BOOLEAN')
bpy.context.object.modifiers["Boolean"].object = newHoles5
bpy.context.object.modifiers["Boolean"].operation = 'UNION'
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
newHoles6 = bpy.context.selected_objects[0]
newHoles6.name = "NewHoles6"

bpy.ops.object.select_all(action='SELECT')
bpy.data.objects['NewHoles6'].select_set(state=False)
bpy.ops.object.delete()


bpy.ops.mesh.primitive_cylinder_add(vertices=64, radius=holeRadius, depth=holeDepth, location=(-12, 22.5, 2.0))
screw6 = bpy.context.selected_objects[0]
screw6.name="Screw6"

bpy.ops.object.modifier_add(type='BOOLEAN')
bpy.context.object.modifiers["Boolean"].object = newHoles6
bpy.context.object.modifiers["Boolean"].operation = 'UNION'
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
newHoles7 = bpy.context.selected_objects[0]
newHoles7.name = "NewHoles7"

bpy.ops.object.select_all(action='SELECT')
bpy.data.objects['NewHoles7'].select_set(state=False)
bpy.ops.object.delete()


bpy.ops.mesh.primitive_cylinder_add(vertices=64, radius=holeRadius, depth=holeDepth, location=(-12, -22.5, 2.0))
screw7 = bpy.context.selected_objects[0]
screw7.name="Screw7"

bpy.ops.object.modifier_add(type='BOOLEAN')
bpy.context.object.modifiers["Boolean"].object = newHoles7
bpy.context.object.modifiers["Boolean"].operation = 'UNION'
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
allTheHoles = bpy.context.selected_objects[0]
allTheHoles.name = "AllTheHoles"

bpy.ops.object.select_all(action='SELECT')
bpy.data.objects['AllTheHoles'].select_set(state=False)
bpy.ops.object.delete()

#bpy.data.objects['AllTheHoles'].select_set(state=False)
bpy.data.objects["AllTheHoles"].location.x += 12.0

bpy.ops.mesh.primitive_cylinder_add(vertices=64, radius=basePlateRadius, depth=basePlateDepth, location=(0,0,basePlateDepth/2.0))
baseplate = bpy.context.selected_objects[0]
baseplate.name="BasePlate"

bpy.ops.object.modifier_add(type='BOOLEAN')
bpy.context.object.modifiers["Boolean"].object = allTheHoles
bpy.context.object.modifiers["Boolean"].operation = 'DIFFERENCE'
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")

bpy.ops.object.select_all(action='SELECT')
bpy.data.objects['BasePlate'].select_set(state=False)
bpy.ops.object.delete()


#newHoles8 = bpy.context.selected_objects[0]
#newHoles8.name = ""


##bpy.ops.object.select_all(action='DESELECT')
#bpy.context.scene.objects.active = bpy.data.objects['Cylinder']
# bpy.ops.object.select_pattern(pattern = 'tube')
#motormount mount hole 11,22 11,-22, 35,0