This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
projects:tesla_car:doorhandles [2018/05/02 00:37] – created admin | projects:tesla_car:doorhandles [2018/09/11 00:50] (current) – [Mylar sheet] admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | = Tesla Model S door handles = | + | ====== Tesla Model S door handles |
Until about 2017, the Model S door handles suffered two problems. These were: | Until about 2017, the Model S door handles suffered two problems. These were: | ||
* Water ingress damaged multiple parts. These were: | * Water ingress damaged multiple parts. These were: | ||
Line 9: | Line 9: | ||
* Non working LED illumination module was probably hammered in by Tesla, which caused cracks in the plastic with water ingress and corrosion as a consequence. | * Non working LED illumination module was probably hammered in by Tesla, which caused cracks in the plastic with water ingress and corrosion as a consequence. | ||
- | == Remedy RR-RH == | + | ==== Remedy RR-RH ==== |
Original part after taking out: | Original part after taking out: | ||
+ | {{ : | ||
- | + | A solution for the switches was to combine both moving switches in a stationary holder. After designing with FreeCAD, the following came out: | |
+ | |||
+ | ==== Mylar sheet ==== | ||
+ | One of the objectives is to make the doorhandles water-proof. For this the following material has been tested: | ||
+ | * IASOPET OAN 26μm, Zolltarif PET Folie 39206219, BOPP Folie 39202021 (delivered from the company Strohmeier+Ernst GmbH & Co KG, Pilgerplatt 10, 33378 Rheda-Wiedenbrück, | ||
+ | * Hostaphan RNT/36μm, (Delivered by the company Pütz GmbH + Co. Folien KG, Obere Waldstr. 26 + 26a, 65232 Taunusstein-Wehen, | ||
+ | |||
+ | ==== FreeCad ==== | ||
+ | The following script creates the RR_RH part: | ||
+ | <code python> | ||
+ | # | ||
+ | # This script creates a small 3d printable enclosure for two switches | ||
+ | # to improve the constuction of a tesla retracting door handle. | ||
+ | # | ||
+ | # copyright: Marc Nijdam | ||
+ | # Date of creation: 05.02.2018 | ||
+ | # | ||
+ | |||
+ | # To run this independent of an instance of freecad, uncomment following lines. | ||
+ | #import sys | ||
+ | # | ||
+ | #import FreeCAD | ||
+ | #import FreeCADGui | ||
+ | # Otherwise, copy paste this code into the freecad python console. | ||
+ | |||
+ | import WebGui | ||
+ | import PartDesignGui | ||
+ | import math | ||
+ | import Part | ||
+ | import os.path | ||
+ | |||
+ | # helper functions | ||
+ | |||
+ | # sketches a line from a to b on a sketch object: App.getDocument(" | ||
+ | def sketch_line(pl_obj, | ||
+ | return pl_obj.addGeometry(Part.LineSegment(App.Vector(a[0], | ||
+ | |||
+ | # returns sum of two coordinates | ||
+ | def addp(a, | ||
+ | return ([a[0] + b[0], a[1] + b[1]]) | ||
+ | |||
+ | # | ||
+ | # coordinate system | ||
+ | # | ||
+ | # ! | ||
+ | # ! | ||
+ | # ! | ||
+ | # ^ ! | ||
+ | # y !_(o)! | ||
+ | # | ||
+ | # x > | ||
+ | # | ||
+ | # creation mode: 0:final shape, 1:3d printable shape | ||
+ | print_3d = 1 | ||
+ | # parameters: stack | ||
+ | hb = 2.0 # height of bottom area | ||
+ | hb1 = 4.0 # thickness of base 1 | ||
+ | hb_mid = 4.0 # thickness of base_mid | ||
+ | # parameters: wall thickness | ||
+ | # | ||
+ | # ! !## | ||
+ | # ! !1 | ||
+ | # ! !## | ||
+ | # ^ ! | ||
+ | # y !_(o)! | ||
+ | # | ||
+ | # x > | ||
+ | tw1 = 1.8 # thickness wall 1 | ||
+ | tw2 = 1.0 # thickness wall 2 | ||
+ | tw3 = 1.8 # thickness wall 3 | ||
+ | tw4 = 1.8 # thickness wall 4 | ||
+ | # parameters: switch Panasonic ASQ10410 | ||
+ | sw_dim = [5.4, 13.3, 12.3] # switch (W x L x H) | ||
+ | sw_area = [13.4, 10.0, hb] # left bottom area where switches are [x,y,z] | ||
+ | sw_offset = [2.71, 6.66, 7.25] # offset for switch left bottom front corner | ||
+ | sw_rotation = [90, 0, 90] # default rotation angle for importing switch | ||
+ | sw_gap = 0.1 # extra margin around switch | ||
+ | bc_vpos = 3.2 # bottom corner vertical space | ||
+ | # | ||
+ | # (switch side view) | ||
+ | # | ||
+ | # _^_ | ||
+ | # ! ! | ||
+ | # ##### | ||
+ | # | ||
+ | # | ||
+ | # ! () {} ! () pin {} hole | ||
+ | # | ||
+ | # # | ||
+ | # left bottom ^ | ||
+ | # corner is reference point (0,0) | ||
+ | # | ||
+ | sw_pin = [2.7, 7.2] # position of pin referenced to left bottom corner | ||
+ | pin_d = 3.0 # diameter of side pins at switches | ||
+ | pin_p = 1.5 # sideways distance of protruding pin | ||
+ | sw_hole = [2.7 + 8.3, 7.2] # position of hole referenced to left bottom corner | ||
+ | # | ||
+ | # | ||
+ | # _..__ _ | ||
+ | # | ||
+ | # '' | ||
+ | # [||__<> | ||
+ | # '' | ||
+ | # Total width for reciprocal switch mounting: 2.7 + 11.0 = 13.7mm = sw_pin[0] + (sw_dim[1] - (sw_dim[1] - sw_hole[0])) | ||
+ | # = sw_pin[0] + sw_hole[0] | ||
+ | # Therefore y dimension of wall 2 to position in sw_area = max(sw_dim[1], | ||
+ | sw_fname = "/ | ||
+ | # parameters: mounting hole position | ||
+ | mnt_pos = [10.0, 5.0] # [x,y] | ||
+ | mnt_hole1 = 10.0 # diameter of hole at base 1 | ||
+ | mnt_hole2 = 3.0 # diameter of hole at base 2 | ||
+ | # parameters: total object size | ||
+ | obj_dim = [26.0, 26.0, sw_dim[2] + hb + sw_gap] # maximum dimensions of object | ||
+ | # parameters: pipe dimensions | ||
+ | w_trench = 2.5 # diameter of trench for cable | ||
+ | # parameters: small corner to cut away | ||
+ | crn_dim = [3.0, 1.5, obj_dim[2]] # small corner to cut material away | ||
+ | crn_c_angle = 88 # ref drawing 9b | ||
+ | # Screwhead | ||
+ | screw_head_d = 4 # screwhead diameter | ||
+ | |||
+ | ### deriving points | ||
+ | # | ||
+ | # calculations based on choniometrical identities | ||
+ | # Using: | ||
+ | # | ||
+ | # | ||
+ | # point F is pivot point | ||
+ | # point A, B, C, D, F, I, J, K and L are fixed points. | ||
+ | # other points depend on value of w and w_trench. | ||
+ | # Point X is in the middle, between point I and L | ||
+ | # | ||
+ | # Line PS is perpendicular to line MN (drawing is not to scale) | ||
+ | # | ||
+ | # ! B----------------------------------C | ||
+ | # ! | | | ||
+ | # ! | J---------------------------K | ||
+ | # ! | | | ||
+ | # ! | | | ||
+ | # ! | | | ||
+ | # ! | | | ||
+ | # ! | | | ||
+ | # ! | | | ||
+ | # ! | I------Q | ||
+ | # ! | \ | ||
+ | # ! A-----H | ||
+ | # ! | ||
+ | # ! \ | ||
+ | # ! | ||
+ | # ! \ | ||
+ | # ! | ||
+ | # ! (0) | ||
+ | # ! ) | ||
+ | # ! _/ | ||
+ | # !--------------------- | ||
+ | # (Drawing 4 - wall) | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # In the middle between points U and W, is point V, which is also | ||
+ | # the middle point between points X and F. The line UW is perpendicular | ||
+ | # to line XZ. Furthermore, | ||
+ | # UW = 0.5 * w_trench + w | ||
+ | # | ||
+ | # With that we can calculate the angles a and b which we use to calculate | ||
+ | # the coordinates of the remaining points. | ||
+ | # | ||
+ | sw_width = max(sw_dim[1], | ||
+ | Xmax = min(sw_area[0] + sw_dim[0] * 2 + tw3, obj_dim[0]) # Make sure, wall thickness never exceed maximum object size | ||
+ | Ymax = min(sw_area[1] + sw_width + tw2, obj_dim[1]) # Make sure, wall thickness never exceed maximum object size | ||
+ | w = max(max(max(tw1, | ||
+ | m = (0.5 * w_trench + w) * 0.5 | ||
+ | XV = math.sqrt( ((obj_dim[0] - sw_area[0] - sw_dim[0]) / 2) ** 2 + ((sw_area[1] - bc_vpos) / 2) ** 2) | ||
+ | a = math.asin(m/ | ||
+ | b = math.asin( (sw_area[1] - bc_vpos) / (XV * 2) ) # in radians | ||
+ | wh_trench = w_trench / math.sin(a + b) | ||
+ | wh = w / math.sin(a + b) | ||
+ | |||
+ | # outer wall | ||
+ | pt_a = [sw_area[0] - tw1, sw_area[1] - tw4] # starting point | ||
+ | pt_b = [sw_area[0] - tw1, Ymax] | ||
+ | pt_c = [Xmax, Ymax] | ||
+ | pt_d = [Xmax, sw_area[1] - tw4] | ||
+ | pt_f = [obj_dim[0], | ||
+ | pt_x = [sw_area[0] + sw_dim[0], sw_area[1]] | ||
+ | pt_e = [obj_dim[0] - (sw_area[1] - tw4 - bc_vpos) / math.tan(a + b), sw_area[1] - tw4] | ||
+ | pt_g = addp(pt_f, [ - (2 * wh + wh_trench), 0]) | ||
+ | pt_h = [pt_g[0] - (pt_f[0] - pt_e[0]), pt_a[1]] | ||
+ | |||
+ | # inner wall | ||
+ | pt_i = [sw_area[0], | ||
+ | pt_j = addp(pt_b, [tw1, -tw2]) | ||
+ | pt_k = addp(pt_c, [-tw3, -tw2]) | ||
+ | pt_l = addp(pt_d, [-tw3, tw4]) | ||
+ | pt_m = addp(pt_x, [wh_trench/ | ||
+ | pt_n = [pt_m[0] + (sw_area[1] - bc_vpos - w) / math.tan(a + b), bc_vpos + w] | ||
+ | pt_p = addp(pt_n, [-wh_trench, | ||
+ | pt_q = addp(pt_m, [-wh_trench, | ||
+ | |||
+ | # Initialization | ||
+ | App.newDocument(" | ||
+ | App.setActiveDocument(" | ||
+ | App.ActiveDocument=App.getDocument(" | ||
+ | Gui.ActiveDocument=Gui.getDocument(" | ||
+ | App.activeDocument().saveAs("/ | ||
+ | ad = App.getDocument(" | ||
+ | gd = Gui.getDocument(" | ||
+ | |||
+ | # 0. Create grid (key g, key r), set camera position | ||
+ | Gui.activateWorkbench(" | ||
+ | gd.activeView().setCamera('# | ||
+ | |||
+ | # 1. Create sketch for ground object | ||
+ | # | ||
+ | # !#### | ||
+ | # !#### | ||
+ | # !#### | ||
+ | # ^ !######### | ||
+ | # y !# | ||
+ | # | ||
+ | # x > | ||
+ | r = mnt_hole1/ | ||
+ | q = 8.2 # bottom corner horizontal space | ||
+ | a1=-math.asin((mnt_pos[0]-q)/ | ||
+ | a2=-math.pi/ | ||
+ | xa1=mnt_pos[0] + math.sqrt(r ** 2 - (mnt_pos[1]-bc_vpos) ** 2) | ||
+ | ya2=mnt_pos[1] - math.sqrt(r ** 2 - (mnt_pos[0]-q) ** 2) | ||
+ | Gui.activateWorkbench(" | ||
+ | ad.addObject(' | ||
+ | ad.sw_housing_RR_RH.newObject(' | ||
+ | ad.base_sketch.Support = (ad.XY_Plane, | ||
+ | ad.base_sketch.MapMode = ' | ||
+ | Gui.activateWorkbench(' | ||
+ | ActiveSketch = ad.getObject(' | ||
+ | so=ad.base_sketch # sketch object | ||
+ | gd.setEdit(' | ||
+ | sketch_line(so, | ||
+ | sketch_line(so, | ||
+ | sketch_line(so, | ||
+ | sketch_line(so, | ||
+ | sketch_line(so, | ||
+ | sketch_line(so, | ||
+ | sketch_line(so, | ||
+ | sketch_line(so, | ||
+ | sketch_line(so, | ||
+ | sketch_line(so, | ||
+ | so.addGeometry(Part.ArcOfCircle(Part.Circle(App.Vector(mnt_pos[0], | ||
+ | sketch_line(so, | ||
+ | sketch_line(so, | ||
+ | so.addGeometry(Part.Circle(App.Vector(mnt_pos[0], | ||
+ | ad.recompute() | ||
+ | # ... pad base_sketch | ||
+ | Gui.activateWorkbench(' | ||
+ | ad.sw_housing_RR_RH.newObject(" | ||
+ | ad.base.Profile = so | ||
+ | ad.base.Length = hb1 + hb_mid | ||
+ | ad.base.Length2 = 100.000000 | ||
+ | ad.base.Type = 0 | ||
+ | ad.base.UpToFace = None | ||
+ | ad.base.Reversed = 0 | ||
+ | ad.base.Midplane = 0 | ||
+ | ad.base.Offset = 0.000000 | ||
+ | gd.setEdit(' | ||
+ | Gui.Selection.clearSelection() | ||
+ | gd.base.ShapeColor=gd.sw_housing_RR_RH.ShapeColor | ||
+ | gd.base.LineColor=gd.sw_housing_RR_RH.LineColor | ||
+ | gd.base.PointColor=gd.sw_housing_RR_RH.PointColor | ||
+ | gd.base.Transparency=gd.sw_housing_RR_RH.Transparency | ||
+ | gd.base.DisplayMode=gd.sw_housing_RR_RH.DisplayMode | ||
+ | so.ViewObject.Visibility=False | ||
+ | ad.recompute() | ||
+ | gd.resetEdit() | ||
+ | |||
+ | # 2. create maximum size floor under switch area and pad | ||
+ | # | ||
+ | # ! !##### | ||
+ | # ! !##### | ||
+ | # ! !##### | ||
+ | # ^ ! | ||
+ | # y !_(o)! | ||
+ | # | ||
+ | # x > | ||
+ | gd.activeView().viewAxonometric() | ||
+ | ad.sw_housing_RR_RH.newObject(' | ||
+ | ad.floorbase.Support = (ad.XY_Plane, | ||
+ | ad.floorbase.MapMode = ' | ||
+ | Gui.activateWorkbench(' | ||
+ | ActiveSketch = ad.getObject(' | ||
+ | bs=ad.floorbase | ||
+ | gd.setEdit(' | ||
+ | sketch_line(bs, | ||
+ | sketch_line(bs, | ||
+ | sketch_line(bs, | ||
+ | sketch_line(bs, | ||
+ | sketch_line(bs, | ||
+ | sketch_line(bs, | ||
+ | sketch_line(bs, | ||
+ | sketch_line(bs, | ||
+ | ad.recompute() | ||
+ | # ... pad main_switchfloor | ||
+ | Gui.activateWorkbench(' | ||
+ | ad.sw_housing_RR_RH.newObject(" | ||
+ | ad.main_switchfloor.Profile = bs | ||
+ | ad.main_switchfloor.Length = hb | ||
+ | ad.main_switchfloor.Length2 = 100.000000 | ||
+ | ad.main_switchfloor.Type = 0 | ||
+ | ad.main_switchfloor.UpToFace = None | ||
+ | ad.main_switchfloor.Reversed = 0 | ||
+ | ad.main_switchfloor.Midplane = 0 | ||
+ | ad.main_switchfloor.Offset = 0.000000 | ||
+ | gd.setEdit(' | ||
+ | Gui.Selection.clearSelection() | ||
+ | gd.main_switchfloor.ShapeColor=gd.sw_housing_RR_RH.ShapeColor | ||
+ | gd.main_switchfloor.LineColor=gd.sw_housing_RR_RH.LineColor | ||
+ | gd.main_switchfloor.PointColor=gd.sw_housing_RR_RH.PointColor | ||
+ | gd.main_switchfloor.Transparency=gd.sw_housing_RR_RH.Transparency | ||
+ | gd.main_switchfloor.DisplayMode=gd.sw_housing_RR_RH.DisplayMode | ||
+ | bs.ViewObject.Visibility=False | ||
+ | ad.recompute() | ||
+ | gd.resetEdit() | ||
+ | |||
+ | # 3. Create sketch for switch walls and pad | ||
+ | # ref. Drawing 4 - wall | ||
+ | ad.sw_housing_RR_RH.newObject(' | ||
+ | ad.switch_walls_sketch.Support = (ad.main_switchfloor, | ||
+ | ad.switch_walls_sketch.MapMode = ' | ||
+ | gd.setEdit(' | ||
+ | Gui.activateWorkbench(' | ||
+ | ActiveSketch = ad.getObject(' | ||
+ | wsk=ad.switch_walls_sketch | ||
+ | # sketch for outside wall: | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | # sketch for inside wall: | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | sketch_line(wsk, | ||
+ | ad.recompute() | ||
+ | # ... Pad walls | ||
+ | Gui.activateWorkbench(' | ||
+ | ad.sw_housing_RR_RH.newObject(" | ||
+ | ad.switch_walls.Profile = wsk | ||
+ | ad.switch_walls.Length = obj_dim[2] - hb | ||
+ | ad.switch_walls.Length2 = 100.0 | ||
+ | ad.switch_walls.Type = 0 | ||
+ | ad.switch_walls.UpToFace = None | ||
+ | ad.switch_walls.Reversed = 0 | ||
+ | ad.switch_walls.Midplane = 0 | ||
+ | ad.switch_walls.UpToFace = None | ||
+ | gd.setEdit(' | ||
+ | Gui.Selection.clearSelection() | ||
+ | gd.switch_walls.ShapeColor=gd.sw_housing_RR_RH.ShapeColor | ||
+ | gd.switch_walls.LineColor=gd.sw_housing_RR_RH.LineColor | ||
+ | gd.switch_walls.PointColor=gd.sw_housing_RR_RH.PointColor | ||
+ | gd.switch_walls.Transparency=gd.sw_housing_RR_RH.Transparency | ||
+ | gd.switch_walls.DisplayMode=gd.sw_housing_RR_RH.DisplayMode | ||
+ | wsk.ViewObject.Visibility=False | ||
+ | ad.recompute() | ||
+ | gd.resetEdit() | ||
+ | |||
+ | # 5. create a maximum 0.8mm fillet for inside bottom edges | ||
+ | Gui.activateWorkbench(" | ||
+ | ad.sw_housing_RR_RH.newObject(" | ||
+ | ad.Fillet.Radius = min(0.8, w_trench / 4) | ||
+ | ad.Fillet.Base = (App.ActiveDocument.switch_walls, | ||
+ | Gui.Selection.clearSelection() | ||
+ | gd.hide(" | ||
+ | ad.recompute() | ||
+ | gd.setEdit(' | ||
+ | gd.Fillet.ShapeColor=Gui.ActiveDocument.sw_housing_RR_RH.ShapeColor | ||
+ | gd.Fillet.LineColor=Gui.ActiveDocument.sw_housing_RR_RH.LineColor | ||
+ | gd.Fillet.PointColor=Gui.ActiveDocument.sw_housing_RR_RH.PointColor | ||
+ | gd.Fillet.Transparency=Gui.ActiveDocument.sw_housing_RR_RH.Transparency | ||
+ | gd.Fillet.DisplayMode=Gui.ActiveDocument.sw_housing_RR_RH.DisplayMode | ||
+ | ad.recompute() | ||
+ | gd.resetEdit() | ||
+ | |||
+ | # 6. Create sketch for m3 screwhead | ||
+ | ad.sw_housing_RR_RH.newObject(' | ||
+ | ad.screwhead_sketch.Support = (ad.Fillet, | ||
+ | ad.screwhead_sketch.MapMode = ' | ||
+ | gd.setEdit(' | ||
+ | Gui.activateWorkbench(' | ||
+ | ActiveSketch = ad.getObject(' | ||
+ | ssk=ad.screwhead_sketch | ||
+ | ssk.addGeometry(Part.Circle(App.Vector(mnt_pos[0], | ||
+ | ad.recompute() | ||
+ | # ... create a pocket from top downwards | ||
+ | Gui.activateWorkbench(' | ||
+ | ad.sw_housing_RR_RH.newObject(" | ||
+ | ad.screwhead.Profile = ssk | ||
+ | ad.screwhead.Length = obj_dim[2]-(hb1+hb_mid) | ||
+ | ad.screwhead.Length2 = 100.0 | ||
+ | ad.screwhead.Type = 0 | ||
+ | ad.screwhead.UpToFace = None | ||
+ | ad.screwhead.Reversed = 0 | ||
+ | ad.screwhead.Midplane = 0 | ||
+ | ad.screwhead.UpToFace = None | ||
+ | ad.screwhead.Offset = 0.0 | ||
+ | gd.setEdit(' | ||
+ | Gui.Selection.clearSelection() | ||
+ | gd.screwhead.ShapeColor=gd.sw_housing_RR_RH.ShapeColor | ||
+ | gd.screwhead.LineColor=gd.sw_housing_RR_RH.LineColor | ||
+ | gd.screwhead.PointColor=gd.sw_housing_RR_RH.PointColor | ||
+ | gd.screwhead.Transparency=gd.sw_housing_RR_RH.Transparency | ||
+ | gd.screwhead.DisplayMode=gd.sw_housing_RR_RH.DisplayMode | ||
+ | ssk.ViewObject.Visibility=False | ||
+ | ad.recompute() | ||
+ | gd.resetEdit() | ||
+ | |||
+ | # 7. Create sketch for slope | ||
+ | ad.sw_housing_RR_RH.newObject(' | ||
+ | ad.slope_sketch.Support = (ad.screwhead, | ||
+ | ad.slope_sketch.MapMode = ' | ||
+ | gd.setEdit(' | ||
+ | Gui.activateWorkbench(' | ||
+ | ActiveSketch = ad.getObject(' | ||
+ | lsk=ad.slope_sketch | ||
+ | sketch_line(lsk, | ||
+ | sketch_line(lsk, | ||
+ | sketch_line(lsk, | ||
+ | sketch_line(lsk, | ||
+ | ad.recompute() | ||
+ | # ... create a pocket for the slope with 11.5mm | ||
+ | Gui.activateWorkbench(' | ||
+ | ad.sw_housing_RR_RH.newObject(" | ||
+ | ad.slope.Profile = lsk | ||
+ | ad.slope.Length = sw_area[0] - tw1 | ||
+ | ad.slope.Length2 = 100.0 | ||
+ | ad.slope.Type = 0 | ||
+ | ad.slope.UpToFace = None | ||
+ | ad.slope.Reversed = 0 | ||
+ | ad.slope.Midplane = 0 | ||
+ | ad.slope.UpToFace = None | ||
+ | gd.setEdit(' | ||
+ | Gui.Selection.clearSelection() | ||
+ | gd.slope.ShapeColor=gd.sw_housing_RR_RH.ShapeColor | ||
+ | gd.slope.LineColor=gd.sw_housing_RR_RH.LineColor | ||
+ | gd.slope.PointColor=gd.sw_housing_RR_RH.PointColor | ||
+ | gd.slope.Transparency=gd.sw_housing_RR_RH.Transparency | ||
+ | gd.slope.DisplayMode=gd.sw_housing_RR_RH.DisplayMode | ||
+ | lsk.ViewObject.Visibility=False | ||
+ | ad.recompute() | ||
+ | gd.resetEdit() | ||
+ | |||
+ | # 8. create pockets for switch side pin | ||
+ | # | ||
+ | # | ||
+ | # \ ! ! | ||
+ | # \ ! ! | ||
+ | # \ ! ! | ||
+ | # \ ! ! | ||
+ | # \ !< | ||
+ | # \ ! ! | ||
+ | # \ ! ! | ||
+ | # \ (1) 0 (4) < | ||
+ | # \ | ||
+ | # \ ' | ||
+ | # | ||
+ | # pin radius: pin_d / 2 | ||
+ | # pin thickness: tw1 - 0.3 | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # Pocket 1 | ||
+ | ad.sw_housing_RR_RH.newObject(' | ||
+ | ad.switch1_pocket_sketch.Support = (ad.slope, | ||
+ | ad.switch1_pocket_sketch.MapMode = ' | ||
+ | gd.setEdit(' | ||
+ | Gui.activateWorkbench(' | ||
+ | ActiveSketch = ad.getObject(' | ||
+ | swp1=ad.switch1_pocket_sketch | ||
+ | # all coordinates relative to pin center | ||
+ | sp_0 = [sw_area[1] + sw_pin[0] , obj_dim[2] - sw_dim[2] + sw_pin[1]] | ||
+ | sp_1 = addp(sp_0, [- pin_d / 2, 0]) | ||
+ | sp_2 = [sp_1[0], obj_dim[2]] | ||
+ | sp_3 = addp(sp_2, [pin_d, 0]) | ||
+ | sp_4 = addp(sp_1, [pin_d, 0]) | ||
+ | sketch_line(swp1, | ||
+ | sketch_line(swp1, | ||
+ | sketch_line(swp1, | ||
+ | swp1.addGeometry(Part.ArcOfCircle(Part.Circle(App.Vector(sp_0[0], | ||
+ | ad.recompute() | ||
+ | # ... create a pocket for the switch side-pin | ||
+ | Gui.activateWorkbench(' | ||
+ | ad.sw_housing_RR_RH.newObject(" | ||
+ | ad.switch1_pocket.Profile = swp1 | ||
+ | ad.switch1_pocket.Length = tw1 - 0.3 | ||
+ | ad.switch1_pocket.Length2 = 100.0 | ||
+ | ad.switch1_pocket.Type = 0 | ||
+ | ad.switch1_pocket.UpToFace = None | ||
+ | ad.switch1_pocket.Reversed = 0 | ||
+ | ad.switch1_pocket.Midplane = 0 | ||
+ | ad.switch1_pocket.UpToFace = None | ||
+ | gd.setEdit(' | ||
+ | Gui.Selection.clearSelection() | ||
+ | gd.switch1_pocket.ShapeColor=gd.sw_housing_RR_RH.ShapeColor | ||
+ | gd.switch1_pocket.LineColor=gd.sw_housing_RR_RH.LineColor | ||
+ | gd.switch1_pocket.PointColor=gd.sw_housing_RR_RH.PointColor | ||
+ | gd.switch1_pocket.Transparency=gd.sw_housing_RR_RH.Transparency | ||
+ | gd.switch1_pocket.DisplayMode=gd.sw_housing_RR_RH.DisplayMode | ||
+ | swp1.ViewObject.Visibility=False | ||
+ | ad.recompute() | ||
+ | gd.resetEdit() | ||
+ | # Pocket 2 | ||
+ | ad.sw_housing_RR_RH.newObject(' | ||
+ | ad.switch2_pocket_sketch.Support = (ad.switch1_pocket, | ||
+ | ad.switch2_pocket_sketch.MapMode = ' | ||
+ | gd.setEdit(' | ||
+ | Gui.activateWorkbench(' | ||
+ | ActiveSketch = ad.getObject(' | ||
+ | swp2=ad.switch2_pocket_sketch | ||
+ | # all coordinates relative to pin center | ||
+ | sp_0 = [-(sw_area[1] + sw_hole[0]) , obj_dim[2] - sw_dim[2] + sw_pin[1]] | ||
+ | sp_1 = addp(sp_0, [- pin_d / 2, 0]) | ||
+ | sp_2 = [sp_1[0], obj_dim[2]] | ||
+ | sp_3 = addp(sp_2, [pin_d, 0]) | ||
+ | sp_4 = addp(sp_1, [pin_d, 0]) | ||
+ | sketch_line(swp2, | ||
+ | sketch_line(swp2, | ||
+ | sketch_line(swp2, | ||
+ | swp2.addGeometry(Part.ArcOfCircle(Part.Circle(App.Vector(sp_0[0], | ||
+ | ad.recompute() | ||
+ | # ... create a pocket for the switch side-pin | ||
+ | Gui.activateWorkbench(' | ||
+ | ad.sw_housing_RR_RH.newObject(" | ||
+ | ad.switch2_pocket.Profile = swp2 | ||
+ | ad.switch2_pocket.Length = tw3 - 0.3 | ||
+ | ad.switch2_pocket.Length2 = 100.0 | ||
+ | ad.switch2_pocket.Type = 0 | ||
+ | ad.switch2_pocket.UpToFace = None | ||
+ | ad.switch2_pocket.Reversed = 0 | ||
+ | ad.switch2_pocket.Midplane = 0 | ||
+ | ad.switch2_pocket.UpToFace = None | ||
+ | gd.setEdit(' | ||
+ | Gui.Selection.clearSelection() | ||
+ | gd.switch2_pocket.ShapeColor=gd.sw_housing_RR_RH.ShapeColor | ||
+ | gd.switch2_pocket.LineColor=gd.sw_housing_RR_RH.LineColor | ||
+ | gd.switch2_pocket.PointColor=gd.sw_housing_RR_RH.PointColor | ||
+ | gd.switch2_pocket.Transparency=gd.sw_housing_RR_RH.Transparency | ||
+ | gd.switch2_pocket.DisplayMode=gd.sw_housing_RR_RH.DisplayMode | ||
+ | swp2.ViewObject.Visibility=False | ||
+ | ad.recompute() | ||
+ | gd.resetEdit() | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | # 9. cut away small corner | ||
+ | # | ||
+ | # Coordinate system: | ||
+ | # | ||
+ | # ! !#### | ||
+ | # ! !# # | ||
+ | # ! !## ## | ||
+ | # ^ ! | ||
+ | # -y !_(o)! | ||
+ | # +x > | ||
+ | # .--- crn_dim[0] | ||
+ | # \/ | ||
+ | # | ||
+ | # ! ! \ | ||
+ | # ! ! !_ | ||
+ | # 3__ c ! ! | ||
+ | # '' | ||
+ | # | ||
+ | # (drawing 9b - corner cut) | ||
+ | # | ||
+ | # Angle c is somewhat smaller | ||
+ | # than 90 degrees | ||
+ | # | ||
+ | # | ||
+ | ad.sw_housing_RR_RH.newObject(' | ||
+ | ad.corner_cut_sketch.Support = (ad.switch2_pocket, | ||
+ | ad.corner_cut_sketch.MapMode = ' | ||
+ | gd.setEdit(' | ||
+ | Gui.activateWorkbench(' | ||
+ | ActiveSketch = ad.getObject(' | ||
+ | ccs=ad.corner_cut_sketch | ||
+ | cc_1 = [obj_dim[0], | ||
+ | cc_2 = addp(cc_1, [-crn_dim[0], | ||
+ | cc_4 = addp(cc_1, [0 , crn_dim[1]]) | ||
+ | cc_3 = addp(cc_4, [-crn_dim[0], | ||
+ | |||
+ | sketch_line(ccs, | ||
+ | sketch_line(ccs, | ||
+ | sketch_line(ccs, | ||
+ | sketch_line(ccs, | ||
+ | ad.recompute() | ||
+ | gd.resetEdit() | ||
+ | # create pocket | ||
+ | Gui.activateWorkbench(' | ||
+ | ad.sw_housing_RR_RH.newObject(" | ||
+ | ad.corner_cut.Profile = ccs | ||
+ | ad.corner_cut.Length = obj_dim[2] * 1.5 | ||
+ | ad.corner_cut.Length2 = 100.0 | ||
+ | ad.corner_cut.Type = 0 | ||
+ | ad.corner_cut.UpToFace = None | ||
+ | ad.corner_cut.Reversed = 0 | ||
+ | ad.corner_cut.Midplane = 0 | ||
+ | ad.corner_cut.UpToFace = None | ||
+ | gd.setEdit(' | ||
+ | Gui.Selection.clearSelection() | ||
+ | ccs.ViewObject.Visibility=False | ||
+ | gd.corner_cut.ShapeColor=gd.sw_housing_RR_RH.ShapeColor | ||
+ | gd.corner_cut.LineColor=gd.sw_housing_RR_RH.LineColor | ||
+ | gd.corner_cut.PointColor=gd.sw_housing_RR_RH.PointColor | ||
+ | gd.corner_cut.Transparency=gd.sw_housing_RR_RH.Transparency | ||
+ | gd.corner_cut.DisplayMode=gd.sw_housing_RR_RH.DisplayMode | ||
+ | ad.recompute() | ||
+ | gd.resetEdit() | ||
+ | |||
+ | # 10. last final operation: create pocket from | ||
+ | # | ||
+ | # if set, cut out cylinder which cannot be 3d printed | ||
+ | r_circle = mnt_hole1/ | ||
+ | ad.sw_housing_RR_RH.newObject(' | ||
+ | ad.cut_sketch.Support = (ad.corner_cut, | ||
+ | ad.cut_sketch.MapMode = ' | ||
+ | gd.setEdit(' | ||
+ | Gui.activateWorkbench(' | ||
+ | ActiveSketch = ad.getObject(' | ||
+ | csk=ad.cut_sketch | ||
+ | csk.addGeometry(Part.Circle(App.Vector(mnt_pos[0], | ||
+ | ad.recompute() | ||
+ | gd.resetEdit() | ||
+ | # create pocket | ||
+ | Gui.activateWorkbench(' | ||
+ | ad.sw_housing_RR_RH.newObject(" | ||
+ | ad.baseprt.Profile = csk | ||
+ | ad.baseprt.Length = hb1 | ||
+ | ad.baseprt.Length2 = 100.0 | ||
+ | ad.baseprt.Type = 0 | ||
+ | ad.baseprt.UpToFace = None | ||
+ | ad.baseprt.Reversed = 0 | ||
+ | ad.baseprt.Midplane = 0 | ||
+ | ad.baseprt.UpToFace = None | ||
+ | gd.setEdit(' | ||
+ | Gui.Selection.clearSelection() | ||
+ | csk.ViewObject.Visibility=False | ||
+ | gd.baseprt.ShapeColor=gd.sw_housing_RR_RH.ShapeColor | ||
+ | gd.baseprt.LineColor=gd.sw_housing_RR_RH.LineColor | ||
+ | gd.baseprt.PointColor=gd.sw_housing_RR_RH.PointColor | ||
+ | gd.baseprt.Transparency=gd.sw_housing_RR_RH.Transparency | ||
+ | gd.baseprt.DisplayMode=gd.sw_housing_RR_RH.DisplayMode | ||
+ | ad.recompute() | ||
+ | gd.resetEdit() | ||
+ | |||
+ | # 11. import switches if file is present | ||
+ | if os.path.isfile(sw_fname) and print_3d == 1: | ||
+ | import ImportGui | ||
+ | # import switch1 | ||
+ | ImportGui.insert(sw_fname," | ||
+ | App.activeDocument().Part__Feature.Placement=App.Placement(App.Vector(sw_offset[0] + sw_area[0], sw_offset[1] + sw_area[1], sw_offset[2] + sw_area[2] + sw_gap), App.Rotation(90, | ||
+ | #import switch2 | ||
+ | ImportGui.insert(sw_fname," | ||
+ | App.activeDocument().Part__Feature001.Placement=App.Placement(App.Vector(sw_offset[0] + sw_area[0] + sw_dim[0], sw_offset[1] + sw_area[1] + (sw_pin[1] - (sw_dim[1] - sw_hole[1])), | ||
+ | |||
+ | |||
+ | # finished | ||
+ | Gui.SendMsgToActiveView(" | ||
+ | Gui.activeDocument().activeView().viewAxonometric() | ||
+ | </ |