Commits

iorodeo  committed c576226

Added class for making arrays for capillary sensors.

  • Participants
  • Parent commits 1bea158

Comments (0)

Files changed (3)

File arrayed_enclosure.py

+import numpy
+from py2scad import *
+from capillary_enclosure import Capillary_Enclosure
+
+
+class Arrayed_Enclosure(Capillary_Enclosure):
+
+    def __init__(self,params):
+        self.params = params
+        super(Arrayed_Enclosure,self).__init__(self.params)
+
+    def make(self):
+        super(Arrayed_Enclosure,self).make()
+        self.make_array_bottom()
+
+    def make_array_bottom(self):
+        number_of_sensors = self.params['number_of_sensors']
+        sensor_spacing = self.params['sensor_spacing']
+        thickness = self.params['wall_thickness']
+        lid_radius = self.params['lid_radius']
+        overhang = self.params['array_bottom_overhang']
+        bottom_x_overhang = self.params['bottom_x_overhang']
+        bottom_y_overhang = self.params['bottom_y_overhang']
+
+        # Get list of current bottom parts - shifted into position
+        shifted_bottoms = []
+        pos_values = self.get_array_positions()
+        for pos in pos_values:
+            shifted_bottoms.append(Translate(self.bottom,v=(0,pos,0)))
+
+        # Get intersection plate
+        plate_x = self.bottom_x
+        plate_y = self.bottom_y + sensor_spacing*number_of_sensors + 2*overhang
+        plate =  rounded_box(plate_x,plate_y,thickness,radius=lid_radius,round_z=False)
+
+        # Remove holes in plate for arrayed bottoms 
+        cut_block_list = []
+        for pos in pos_values:
+            cut_block = rounded_box(
+                    self.bottom_x-bottom_x_overhang,
+                    self.bottom_y-bottom_y_overhang,
+                    2*thickness,
+                    lid_radius,
+                    round_z=False
+                    )
+            cut_block = Translate(cut_block,v=(0,pos,0))
+            cut_block_list.append(cut_block)
+        diff_list = [plate] + cut_block_list
+        plate = Difference(diff_list)
+
+        # Add in arrayed bottoms
+        union_list = [plate] + shifted_bottoms
+        self.array_bottom = Union(union_list) 
+
+
+
+    def get_assembly(self,**kwargs):
+        show_bottom = kwargs['show_bottom']
+        kwargs['show_bottom'] = False
+        top_parts = super(Arrayed_Enclosure,self).get_assembly(**kwargs)
+        parts_list = []
+
+        # Array top parts
+        pos_values = self.get_array_positions()
+        for pos in pos_values:
+            parts_list.append(Translate(top_parts,v=(0,pos,0)))
+
+        x,y,z = self.params['inner_dimensions']
+        thickness = self.params['wall_thickness']
+        z_shift = -0.5*z - 0.5*thickness
+        array_bottom = Translate(self.array_bottom,v=(0,0,z_shift))
+        if show_bottom:
+            parts_list.append(array_bottom)
+
+        return parts_list
+
+
+    def get_array_positions(self):
+        number_of_sensors = self.params['number_of_sensors']
+        sensor_spacing = self.params['sensor_spacing']
+        array_length = sensor_spacing*number_of_sensors
+        pos_values = numpy.linspace(-0.5*array_length, 0.5*array_length, number_of_sensors)
+        return pos_values
+
+
+
+
+

File make_arrayed_enclosure.py

+from py2scad import *
+from arrayed_enclosure import Arrayed_Enclosure
+from make_enclosure import params
+
+params['number_of_sensors'] = 4
+params['sensor_spacing'] = INCH2MM*2.0
+params['array_bottom_overhang'] = 1.0*INCH2MM
+
+# -----------------------------------------------------------------------------
+if __name__ == '__main__':
+    enclosure = Arrayed_Enclosure(params)
+    enclosure.make()
+
+    part_assembly = enclosure.get_assembly(
+            show_top=True,
+            show_bottom=True, 
+            show_front=True,
+            show_back=True,
+            show_left=True,
+            show_right=True,
+            show_standoffs=True,
+            show_capillary=True,
+            show_sensor=True,
+            show_diffuser=True,
+            show_led_pcb=True,
+            show_guide_plates=True,
+            explode=(0,0,0),
+            )
+    prog_assembly = SCAD_Prog()
+    prog_assembly.fn = 50
+    prog_assembly.add(part_assembly)
+    prog_assembly.write('arrayed_assembly.scad')
+
+
+
+

File make_enclosure.py

         'guide_hole_offset'                : 0.15*INCH2MM,
         }
 
+# -----------------------------------------------------------------------------
+if __name__ == '__main__':
+    
+    enclosure = Capillary_Enclosure(params)
+    enclosure.make()
+    
+    part_assembly = enclosure.get_assembly(
+            show_top=False,
+            show_bottom=True, 
+            show_front=False,
+            show_back=False,
+            show_left=False,
+            show_right=False,
+            show_standoffs=True,
+            show_capillary=True,
+            show_sensor=False,
+            show_diffuser=True,
+            show_led_pcb=True,
+            show_guide_plates=True,
+            explode=(0,0,0),
+            )
+    
+    
+    #print enclosure.standoff_xy_pos
+    box_projection = enclosure.get_box_projection()
+    diffuser_projection = enclosure.get_diffuser_projection()
+    top_guide_projection = enclosure.get_guide_top_projection()
+    side_guide_projection = enclosure.get_guide_side_projection()
+    
+    prog_assembly = SCAD_Prog()
+    prog_assembly.fn = 50
+    prog_assembly.add(part_assembly)
+    prog_assembly.write('enclosure_assembly.scad')
+    
+    prog_box_projection = SCAD_Prog()
+    prog_box_projection.fn = 50
+    prog_box_projection.add(box_projection)
+    prog_box_projection.write('box_projection.scad')
+    
+    prog_diffuser_projection = SCAD_Prog()
+    prog_diffuser_projection.fn = 50
+    prog_diffuser_projection.add(diffuser_projection)
+    prog_diffuser_projection.write('diffuser_projection.scad')
+    
+    prog_top_guide_projection = SCAD_Prog()
+    prog_top_guide_projection.fn = 50
+    prog_top_guide_projection.add(top_guide_projection)
+    prog_top_guide_projection.write('top_guide_projection.scad')
+    
+    prog_side_guide_projection = SCAD_Prog()
+    prog_side_guide_projection.fn = 50
+    prog_side_guide_projection.add(side_guide_projection)
+    prog_side_guide_projection.write('side_guide_projection.scad')
 
-enclosure = Capillary_Enclosure(params)
-enclosure.make()
-
-part_assembly = enclosure.get_assembly(
-        show_top=False,
-        show_bottom=True, 
-        show_front=False,
-        show_back=False,
-        show_left=False,
-        show_right=False,
-        show_standoffs=True,
-        show_capillary=True,
-        show_sensor=False,
-        show_diffuser=True,
-        show_led_pcb=True,
-        show_guide_plates=True,
-        explode=(0,0,0),
-        )
-
-
-#print enclosure.standoff_xy_pos
-box_projection = enclosure.get_box_projection()
-diffuser_projection = enclosure.get_diffuser_projection()
-top_guide_projection = enclosure.get_guide_top_projection()
-side_guide_projection = enclosure.get_guide_side_projection()
-
-prog_assembly = SCAD_Prog()
-prog_assembly.fn = 50
-prog_assembly.add(part_assembly)
-prog_assembly.write('enclosure_assembly.scad')
-
-prog_box_projection = SCAD_Prog()
-prog_box_projection.fn = 50
-prog_box_projection.add(box_projection)
-prog_box_projection.write('box_projection.scad')
-
-prog_diffuser_projection = SCAD_Prog()
-prog_diffuser_projection.fn = 50
-prog_diffuser_projection.add(diffuser_projection)
-prog_diffuser_projection.write('diffuser_projection.scad')
-
-prog_top_guide_projection = SCAD_Prog()
-prog_top_guide_projection.fn = 50
-prog_top_guide_projection.add(top_guide_projection)
-prog_top_guide_projection.write('top_guide_projection.scad')
-
-prog_side_guide_projection = SCAD_Prog()
-prog_side_guide_projection.fn = 50
-prog_side_guide_projection.add(side_guide_projection)
-prog_side_guide_projection.write('side_guide_projection.scad')
-