def generate_pin(num_pins, calc_dim): pin_group_width = calc_dim.pin_group_width pin_width = series_params.pin_width pin_thickness = series_params.pin_thickness pin_pitch = series_params.pitch body_width = series_params.body_width pin_minimum_radius = series_params.pin_minimum_radius pin_y_offset = series_params.pin_y_offset p_list = [('start', { 'position': ((-body_width / 2 - pin_y_offset, pin_thickness / 2.0)), 'direction': 0.0, 'width': pin_thickness }), ('line', { 'length': pin_y_offset }), ('arc', { 'radius': pin_minimum_radius, 'angle': 60.0 }), ('line', { 'length': 0.05 }), ('arc', { 'radius': pin_minimum_radius, 'angle': -60.0 }), ('line', { 'length': 0.4 })] ribbon = Ribbon( cq.Workplane("YZ").workplane(offset=-pin_width / 2.0 - pin_group_width / 2.0), p_list) pin = ribbon.drawRibbon().extrude(pin_width) return pin
def generate_contact(calc_dim): pin_group_width = calc_dim.pin_group_width contact_width = series_params.contact_width contact_thickness = series_params.contact_thickness contact_minimum_radius = series_params.contact_minimum_radius pin_pitch = series_params.pitch pocket_width = series_params.pocket_width body_height = series_params.body_height pocket_base_thickness = series_params.pocket_base_thickness c_list = [('start', { 'position': ((-pocket_width / 2 - contact_thickness / 2.0, pocket_base_thickness)), 'direction': 90.0, 'width': contact_thickness }), ('line', { 'length': body_height - pocket_base_thickness - contact_minimum_radius - contact_thickness / 2.0 }), ('arc', { 'radius': contact_minimum_radius, 'angle': 90.0 }), ('line', { 'length': 0.25 })] ribbon = Ribbon( cq.Workplane("YZ").workplane(offset=-contact_width / 2.0 - pin_group_width / 2.0), c_list) contact = ribbon.drawRibbon().extrude(contact_width) contact = contact.faces("<Y").edges("|Z").chamfer((contact_width / 2.0) - 0.01) return contact
def _build_pins(self, dim, cut_pin): pin = cq.Workplane("XZ")\ .workplane(offset=-(dim.pin_y_mm/2.0 + (dim.number_pins - 1) * dim.pin_pitch_mm/2.0)) pin = Ribbon(pin, dim.pin_profile).drawRibbon().extrude(dim.pin_y_mm) pins = pin for i in range(0, dim.number_pins): pins = pins.union(pin.translate((0, -i * dim.pin_pitch_mm, 0))) if cut_pin: cutter = cq.Workplane("XY")\ .moveTo(dim.body_centre_x_mm -(dim.body_x_mm / 2.0) - dim.pin_cut_x_mm - 5.0, 0)\ .rect(2*5.0, dim.pin_fat_y_mm).extrude(dim.body_z_mm) pins = pins.cut(cutter) return pins
def generate_2_contact_group(params): pin_y_pitch = params.pin_y_pitch foot_height = seriesParams.foot_height pin_thickness = seriesParams.pin_thickness pin_width = seriesParams.pin_width y_offset = -(2 * pin_y_pitch) c_list = [ ('start', { 'position': (pin_y_pitch, foot_height), 'direction': 90.0, 'width': pin_thickness }), ('line', { 'length': 4.5 }), ('arc', { 'radius': 0.2, 'angle': 35.0 }), ('line', { 'length': 3 }), ('arc', { 'radius': 2.0, 'angle': -70.0 }), ('line', { 'length': 2 }), ('arc', { 'radius': 0.2, 'angle': 35.0 }), ('line', { 'length': 2.8 }), ] ribbon = Ribbon( cq.Workplane("YZ").workplane(offset=-pin_width / 2.0), c_list) contact1 = ribbon.drawRibbon().extrude(pin_width) contact2 = contact1.mirror("XZ") contact1 = contact1.union(contact2).translate( (0, -3 * pin_y_pitch / 2.0, 0)) return contact1
def generate_contact(calc_dim): pin_group_width = calc_dim.pin_group_width contact_width = series_params.contact_width contact_thickness = series_params.contact_thickness contact_minimum_radius = series_params.contact_minimum_radius pin_pitch = series_params.pitch pocket_width = series_params.pocket_width body_height = series_params.body_height pocket_base_thickness = series_params.pocket_base_thickness c_list = [ ('start', {'position': ((-pocket_width/2 - contact_thickness / 2.0, pocket_base_thickness)), 'direction': 90.0, 'width':contact_thickness}), ('line', {'length': body_height - pocket_base_thickness - contact_minimum_radius - contact_thickness / 2.0}), ('arc', {'radius': contact_minimum_radius, 'angle': 90.0}), ('line', {'length': 0.25}) ] ribbon = Ribbon(cq.Workplane("YZ").workplane(offset=-contact_width/2.0 - pin_group_width/2.0), c_list) contact = ribbon.drawRibbon().extrude(contact_width) contact = contact.faces("<Y").edges("|Z").chamfer((contact_width / 2.0)- 0.01) return contact
def generate_pin(num_pins, calc_dim): pin_group_width = calc_dim.pin_group_width pin_width = series_params.pin_width pin_thickness = series_params.pin_thickness pin_pitch = series_params.pitch body_width = series_params.body_width pin_minimum_radius = series_params.pin_minimum_radius pin_y_offset = series_params.pin_y_offset p_list = [ ('start', {'position': ((-body_width/2 - pin_y_offset, pin_thickness/2.0)), 'direction': 0.0, 'width':pin_thickness}), ('line', {'length': pin_y_offset}), ('arc', {'radius': pin_minimum_radius, 'angle': 60.0}), ('line', {'length': 0.05}), ('arc', {'radius': pin_minimum_radius, 'angle': -60.0}), ('line', {'length': 0.4}) ] ribbon = Ribbon(cq.Workplane("YZ").workplane(offset=-pin_width/2.0 - pin_group_width/2.0), p_list) pin = ribbon.drawRibbon().extrude(pin_width) return pin
def generate_contact(calc_dim): pin_group_width = calc_dim.pin_group_width pin_width = series_params.pin_width pin_thickness = series_params.pin_thickness pin_minimum_radius = series_params.pin_minimum_radius pitch = series_params.pitch pin_y_offset = series_params.pin_y_offset body_width = series_params.body_width hole_length = series_params.hole_length-0.02 hole_offset = series_params.hole_offset slot_height = series_params.slot_height c1_list = [ ('start', {'position': ((-body_width/2 - pin_y_offset, pin_thickness/2.0)), 'direction': 0.0, 'width':pin_thickness}), ('line', {'length': pin_y_offset}), ('arc', {'radius': pin_minimum_radius, 'angle': 60.0}), ('line', {'length': 0.05}), ('arc', {'radius': pin_minimum_radius, 'angle': -60.0}), ('line', {'length': 0.8}), ('arc', {'radius': pin_minimum_radius, 'angle': -45.0}), ('arc', {'radius': pin_minimum_radius, 'angle': 45.0}), ('line', {'length': 0.63}), ('arc', {'radius': 0.15, 'angle': 95.0}), ('line', {'length': 0.5}), ('arc', {'radius': 0.1, 'angle': 85.0}) ] ribbon = Ribbon(cq.Workplane("YZ").workplane(offset=-pin_width/2.0 - pin_group_width/2.0), c1_list) contact1 = ribbon.drawRibbon().extrude(pin_width) c2_list = [ ('start', {'position': ((-hole_offset-hole_length/2.0+pin_thickness/2.0, slot_height-pin_minimum_radius-pin_thickness/2.0)), 'direction': 90.0, 'width':pin_thickness}), ('arc', {'radius': pin_minimum_radius, 'angle': -90.0}), ('line', {'length': hole_length-2.0*pin_minimum_radius-pin_thickness}), ('arc', {'radius': pin_minimum_radius, 'angle': -90.0}), ('line', {'length': slot_height - 0.32}), ('arc', {'radius': pin_minimum_radius, 'angle': 90.0}), ('line', {'length': 0.29}), ('arc', {'radius': 0.1, 'angle': 90.0}), ('line', {'length': 0.45}), ('arc', {'radius': 0.1, 'angle': -90.0}) ] ribbon = Ribbon(cq.Workplane("YZ").workplane(offset=-pin_width/2.0 - pin_group_width/2.0), c2_list) contact2 = ribbon.drawRibbon().extrude(pin_width) contact1 = contact1.union(contact2) return contact1
def generate_2_contact_group(params): pin_y_pitch=params.pin_y_pitch foot_height = seriesParams.foot_height pin_thickness = seriesParams.pin_thickness pin_width=seriesParams.pin_width y_offset = -(2*pin_y_pitch) c_list = [ ('start', {'position': (pin_y_pitch, foot_height), 'direction': 90.0, 'width':pin_thickness}), ('line', {'length': 4.5}), ('arc', {'radius': 0.2, 'angle': 35.0}), ('line', {'length': 3}), ('arc', {'radius': 2.0, 'angle': -70.0}), ('line', {'length': 2}), ('arc', {'radius': 0.2, 'angle': 35.0}), ('line', {'length': 2.8}), ] ribbon = Ribbon(cq.Workplane("YZ").workplane(offset=-pin_width/2.0), c_list) contact1 = ribbon.drawRibbon().extrude(pin_width) contact2 = contact1.mirror("XZ") contact1 = contact1.union(contact2).translate((0,-3*pin_y_pitch/2.0,0)) return contact1
def generate_contact(calc_dim): pin_group_width = calc_dim.pin_group_width pin_width = series_params.pin_width pin_thickness = series_params.pin_thickness pin_minimum_radius = series_params.pin_minimum_radius pitch = series_params.pitch pin_y_offset = series_params.pin_y_offset body_width = series_params.body_width hole_length = series_params.hole_length - 0.02 hole_offset = series_params.hole_offset slot_height = series_params.slot_height c1_list = [('start', { 'position': ((-body_width / 2 - pin_y_offset, pin_thickness / 2.0)), 'direction': 0.0, 'width': pin_thickness }), ('line', { 'length': pin_y_offset }), ('arc', { 'radius': pin_minimum_radius, 'angle': 60.0 }), ('line', { 'length': 0.05 }), ('arc', { 'radius': pin_minimum_radius, 'angle': -60.0 }), ('line', { 'length': 0.8 }), ('arc', { 'radius': pin_minimum_radius, 'angle': -45.0 }), ('arc', { 'radius': pin_minimum_radius, 'angle': 45.0 }), ('line', { 'length': 0.63 }), ('arc', { 'radius': 0.15, 'angle': 95.0 }), ('line', { 'length': 0.5 }), ('arc', { 'radius': 0.1, 'angle': 85.0 })] ribbon = Ribbon( cq.Workplane("YZ").workplane(offset=-pin_width / 2.0 - pin_group_width / 2.0), c1_list) contact1 = ribbon.drawRibbon().extrude(pin_width) c2_list = [('start', { 'position': ((-hole_offset - hole_length / 2.0 + pin_thickness / 2.0, slot_height - pin_minimum_radius - pin_thickness / 2.0)), 'direction': 90.0, 'width': pin_thickness }), ('arc', { 'radius': pin_minimum_radius, 'angle': -90.0 }), ('line', { 'length': hole_length - 2.0 * pin_minimum_radius - pin_thickness }), ('arc', { 'radius': pin_minimum_radius, 'angle': -90.0 }), ('line', { 'length': slot_height - 0.32 }), ('arc', { 'radius': pin_minimum_radius, 'angle': 90.0 }), ('line', { 'length': 0.29 }), ('arc', { 'radius': 0.1, 'angle': 90.0 }), ('line', { 'length': 0.45 }), ('arc', { 'radius': 0.1, 'angle': -90.0 })] ribbon = Ribbon( cq.Workplane("YZ").workplane(offset=-pin_width / 2.0 - pin_group_width / 2.0), c2_list) contact2 = ribbon.drawRibbon().extrude(pin_width) contact1 = contact1.union(contact2) return contact1
from ribbon import Ribbon, RibbonExecutionException # Take any command line tool. # Let's start with `ls` and how to build command lines: ls = Ribbon('ls') # Pass positional args: print ls.build_cmd_str() # ls print ls.build_cmd_str('-a') # ls -a print ls.build_cmd_str('.', '-a') # ls . -a # Keyword args: print ls.build_cmd_str(a=True) # ls -a print ls.build_cmd_str(a=False) # ls print ls.build_cmd_str('.', a=True) # ls . -a # Execute command print ls.getoutput() # LICENSE # README.md # examples.py # ribbon.py # ribbon.pyc # test_ribbon.py print ls.getoutput(a=True, l=True) # total 88 # drwxr-xr-x 10 valiev staff 340 Aug 30 01:23 .bit_lengthdrwxr-xr-x 11 # valiev staff 374 Aug 29 00:04 .. # -rw-r--r-- 1 valiev staff 12288 Aug 30 01:23 .examples.py.swp
def stop(self): # shutdown all running ribbons Ribbon.shutdown() logging.info("Shutdown complete")