Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import bpy
|
| 2 |
+
import math
|
| 3 |
+
|
| 4 |
+
# Clear existing objects
|
| 5 |
+
bpy.ops.object.select_all(action='SELECT')
|
| 6 |
+
bpy.ops.object.delete()
|
| 7 |
+
|
| 8 |
+
def create_band(radius, width, thickness):
|
| 9 |
+
bpy.ops.mesh.primitive_cylinder_add(
|
| 10 |
+
radius=radius,
|
| 11 |
+
depth=width,
|
| 12 |
+
vertices=64
|
| 13 |
+
)
|
| 14 |
+
band = bpy.context.active_object
|
| 15 |
+
bpy.ops.object.mode_set(mode='EDIT')
|
| 16 |
+
bpy.ops.mesh.select_all(action='SELECT')
|
| 17 |
+
bpy.ops.mesh.normals_make_consistent(inside=False)
|
| 18 |
+
bpy.ops.object.mode_set(mode='OBJECT')
|
| 19 |
+
|
| 20 |
+
# Create thickness
|
| 21 |
+
bpy.ops.object.modifier_add(type='SOLIDIFY')
|
| 22 |
+
band.modifiers["Solidify"].thickness = thickness
|
| 23 |
+
band.modifiers["Solidify"].offset = 0
|
| 24 |
+
|
| 25 |
+
return band
|
| 26 |
+
|
| 27 |
+
def create_component(size, location):
|
| 28 |
+
bpy.ops.mesh.primitive_cube_add(size=1, location=location)
|
| 29 |
+
component = bpy.context.active_object
|
| 30 |
+
component.scale = size
|
| 31 |
+
return component
|
| 32 |
+
|
| 33 |
+
# Create main band
|
| 34 |
+
main_band = create_band(radius=0.1, width=0.15, thickness=0.01)
|
| 35 |
+
main_band.location = (0, 0, 0)
|
| 36 |
+
|
| 37 |
+
# Create sensor
|
| 38 |
+
sensor = create_component(size=(0.02, 0.02, 0.01), location=(0.09, 0, 0))
|
| 39 |
+
|
| 40 |
+
# Create vibration motor
|
| 41 |
+
motor = create_component(size=(0.03, 0.03, 0.02), location=(0.09, 0.04, 0))
|
| 42 |
+
|
| 43 |
+
# Create microcontroller
|
| 44 |
+
microcontroller = create_component(size=(0.05, 0.05, 0.01), location=(0, 0.09, 0))
|
| 45 |
+
|
| 46 |
+
# Create battery
|
| 47 |
+
battery = create_component(size=(0.06, 0.04, 0.02), location=(-0.08, 0.05, 0))
|
| 48 |
+
|
| 49 |
+
# Join all objects
|
| 50 |
+
objects_to_join = [main_band, sensor, motor, microcontroller, battery]
|
| 51 |
+
bpy.ops.object.select_all(action='DESELECT')
|
| 52 |
+
for obj in objects_to_join:
|
| 53 |
+
obj.select_set(True)
|
| 54 |
+
bpy.context.view_layer.objects.active = main_band
|
| 55 |
+
bpy.ops.object.join()
|
| 56 |
+
|
| 57 |
+
# Add subdivision surface modifier for smoothing
|
| 58 |
+
bpy.ops.object.modifier_add(type='SUBSURF')
|
| 59 |
+
bpy.context.object.modifiers["Subdivision"].render_levels = 2
|
| 60 |
+
bpy.context.object.modifiers["Subdivision"].levels = 2
|
| 61 |
+
|
| 62 |
+
# Add material
|
| 63 |
+
material = bpy.data.materials.new(name="DeviceMaterial")
|
| 64 |
+
material.use_nodes = True
|
| 65 |
+
bpy.context.active_object.data.materials.append(material)
|
| 66 |
+
|
| 67 |
+
# Set up basic color
|
| 68 |
+
material.node_tree.nodes["Principled BSDF"].inputs["Base Color"].default_value = (0.8, 0.8, 0.8, 1) # Light gray
|
| 69 |
+
material.node_tree.nodes["Principled BSDF"].inputs["Roughness"].default_value = 0.3
|