File size: 2,240 Bytes
e1d9ef5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import bpy
import math

# Clear existing objects
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()

def create_band(radius, width, thickness):
    bpy.ops.mesh.primitive_cylinder_add(
        radius=radius, 
        depth=width,
        vertices=64
    )
    band = bpy.context.active_object
    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.select_all(action='SELECT')
    bpy.ops.mesh.normals_make_consistent(inside=False)
    bpy.ops.object.mode_set(mode='OBJECT')
    
    # Create thickness
    bpy.ops.object.modifier_add(type='SOLIDIFY')
    band.modifiers["Solidify"].thickness = thickness
    band.modifiers["Solidify"].offset = 0
    
    return band

def create_component(size, location):
    bpy.ops.mesh.primitive_cube_add(size=1, location=location)
    component = bpy.context.active_object
    component.scale = size
    return component

# Create main band
main_band = create_band(radius=0.1, width=0.15, thickness=0.01)
main_band.location = (0, 0, 0)

# Create sensor
sensor = create_component(size=(0.02, 0.02, 0.01), location=(0.09, 0, 0))

# Create vibration motor
motor = create_component(size=(0.03, 0.03, 0.02), location=(0.09, 0.04, 0))

# Create microcontroller
microcontroller = create_component(size=(0.05, 0.05, 0.01), location=(0, 0.09, 0))

# Create battery
battery = create_component(size=(0.06, 0.04, 0.02), location=(-0.08, 0.05, 0))

# Join all objects
objects_to_join = [main_band, sensor, motor, microcontroller, battery]
bpy.ops.object.select_all(action='DESELECT')
for obj in objects_to_join:
    obj.select_set(True)
bpy.context.view_layer.objects.active = main_band
bpy.ops.object.join()

# Add subdivision surface modifier for smoothing
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.context.object.modifiers["Subdivision"].render_levels = 2
bpy.context.object.modifiers["Subdivision"].levels = 2

# Add material
material = bpy.data.materials.new(name="DeviceMaterial")
material.use_nodes = True
bpy.context.active_object.data.materials.append(material)

# Set up basic color
material.node_tree.nodes["Principled BSDF"].inputs["Base Color"].default_value = (0.8, 0.8, 0.8, 1)  # Light gray
material.node_tree.nodes["Principled BSDF"].inputs["Roughness"].default_value = 0.3