Esempio n. 1
0
    def __init__(self,
                 r_ext,
                 r_int,
                 h,
                 name,
                 axis='z',
                 h_disp=0,
                 r_tol=0,
                 h_tol=0):

        self.base_place = (0, 0, 0)
        self.r_ext = r_ext
        self.r_int = r_int
        self.h = h
        self.name = name
        self.axis = axis
        self.h_disp = h_disp
        self.r_tol = r_tol
        self.h_tol = h_tol

        bearing = fcfun.addCylHole(r_ext=r_ext,
                                   r_int=r_int,
                                   h=h,
                                   name=name,
                                   axis=axis,
                                   h_disp=h_disp)
        self.bearing = bearing

        bearing_cont = fcfun.addCyl_pos(r=r_ext + r_tol,
                                        h=h + h_tol,
                                        name=name + "_cont",
                                        axis=axis,
                                        h_disp=h_disp - h_tol / 2.0)
        # Hide the container
        self.bearing_cont = bearing_cont
        if bearing_cont.ViewObject != None:
            bearing_cont.ViewObject.Visibility = False
Esempio n. 2
0
    def __init__(self, name, nutaxis='x'):
        doc = FreeCAD.ActiveDocument
        self.name = name
        self.nutaxis = nutaxis

        flange_cyl = addCyl_pos(r=self.FlangeR,
                                h=self.FlangeL,
                                name="flange_cyl",
                                axis='z',
                                h_disp=-self.FlangeL)

        shaft_cyl = addCyl_pos(r=self.ShaftR,
                               h=self.NutL,
                               name="shaft_cyl",
                               axis='z',
                               h_disp=-self.NutL + self.ShaftOut)

        holes_list = []

        leadscrew_hole = addCyl_pos(r=self.LeadScrewR,
                                    h=self.NutL + 2,
                                    name="leadscrew_hole",
                                    axis='z',
                                    h_disp=-self.NutL + self.ShaftOut - 1)
        holes_list.append(leadscrew_hole)

        flangescrew_hole1 = addCyl_pos(r=self.FlangeScrewHoleD / 2.0,
                                       h=self.FlangeL + 2,
                                       name="flangescrew_hole1",
                                       axis='z',
                                       h_disp=-self.FlangeL - 1)
        flangescrew_hole1.Placement.Base.x = self.FlangeScrewPosD / 2.0
        holes_list.append(flangescrew_hole1)

        flangescrew_hole2 = addCyl_pos(r=self.FlangeScrewHoleD / 2.0,
                                       h=self.FlangeL + 2,
                                       name="flangescrew_hole2",
                                       axis='z',
                                       h_disp=-self.FlangeL - 1)
        flangescrew_hole2.Placement.Base.x = -self.FlangeScrewPosD / 2.0
        holes_list.append(flangescrew_hole2)

        flangescrew_hole3 = addCyl_pos(r=self.FlangeScrewHoleD / 2.0,
                                       h=self.FlangeL + 2,
                                       name="flangescrew_hole3",
                                       axis='z',
                                       h_disp=-self.FlangeL - 1)
        flangescrew_hole3.Placement.Base.y = self.FlangeScrewPosD / 2.0
        holes_list.append(flangescrew_hole3)

        flangescrew_hole4 = addCyl_pos(r=self.FlangeScrewHoleD / 2.0,
                                       h=self.FlangeL + 2,
                                       name="flangescrew_hole4",
                                       axis='z',
                                       h_disp=-self.FlangeL - 1)
        flangescrew_hole4.Placement.Base.y = -self.FlangeScrewPosD / 2.0
        holes_list.append(flangescrew_hole4)

        nut_holes = doc.addObject("Part::MultiFuse", "nut_holes")
        nut_holes.Shapes = holes_list

        nut_cyls = doc.addObject("Part::Fuse", "nut_cyls")
        nut_cyls.Base = flange_cyl
        nut_cyls.Tool = shaft_cyl

        if nutaxis == 'x':
            vrot = FreeCAD.Rotation(VY, 90)
        elif nutaxis == '-x':
            vrot = FreeCAD.Rotation(VY, -90)
        elif nutaxis == 'y':
            vrot = FreeCAD.Rotation(VX, -90)
        elif nutaxis == '-y':
            vrot = FreeCAD.Rotation(VX, 90)
        elif nutaxis == '-z':
            vrot = FreeCAD.Rotation(VX, 180)
        else:  # nutaxis =='z' no rotation
            vrot = FreeCAD.Rotation(VZ, 0)

        nut_cyls.Placement.Rotation = vrot
        nut_holes.Placement.Rotation = vrot

        t8nut = doc.addObject("Part::Cut", "t8nut")
        t8nut.Base = nut_cyls
        t8nut.Tool = nut_holes
        # recompute before color
        doc.recompute()
        t8nut.ViewObject.ShapeColor = fcfun.YELLOW

        self.fco = t8nut  # the FreeCad Object
Esempio n. 3
0
    def __init__(self,
                 name,
                 nutaxis='x',
                 screwface_axis='z',
                 cx=1,
                 cy=1,
                 cz=0):
        self.name = name
        self.nutaxis = nutaxis
        self.screwface_axis = screwface_axis
        self.cx = cx
        self.cy = cy
        self.cz = cz

        doc = FreeCAD.ActiveDocument
        # centered so it can be rotated without displacement, and everything
        # will be in place
        housing_box = fcfun.addBox_cen(self.Length,
                                       self.Width,
                                       self.Height,
                                       name=name + "_box",
                                       cx=True,
                                       cy=True,
                                       cz=True)

        hole_list = []

        leadscr_hole = addCyl_pos(r=self.ShaftR,
                                  h=self.Length + 1,
                                  name="leadscr_hole",
                                  axis='x',
                                  h_disp=-self.Length / 2.0 - 1)
        hole_list.append(leadscr_hole)
        nutflange_hole = addCyl_pos(r=self.FlangeR,
                                    h=self.FlangeL + 1,
                                    name="nutflange_hole",
                                    axis='x',
                                    h_disp=self.Length / 2.0 - self.FlangeL)
        hole_list.append(nutflange_hole)
        # screws to attach the nut flange to the housing
        # M3 x 10
        screwflange_l = addCyl_pos(r=self.FlangeScrewR,
                                   h=self.FlangeScrewL + 1,
                                   name="screwflange_l",
                                   axis='x',
                                   h_disp=self.Length / 2.0 - self.FlangeL -
                                   self.FlangeScrewL)
        screwflange_l.Placement.Base = FreeCAD.Vector(
            0,
            -self.FlangeScrewPosD / 2.0,
        )
        hole_list.append(screwflange_l)
        screwflange_r = addCyl_pos(r=self.FlangeScrewR,
                                   h=self.FlangeScrewL + 1,
                                   name="screwflange_r",
                                   axis='x',
                                   h_disp=self.Length / 2.0 - self.FlangeL -
                                   self.FlangeScrewL)
        screwflange_r.Placement.Base = FreeCAD.Vector(
            0, self.FlangeScrewPosD / 2.0, 0)
        hole_list.append(screwflange_r)

        # screws to attach the housing to the moving part
        # M4x7
        screwface_1 = fcfun.addCyl_pos(r=self.ScrewR,
                                       h=self.ScrewL + 1,
                                       name="screwface_1",
                                       axis='z',
                                       h_disp=-self.Height / 2 - 1)
        screwface_1.Placement.Base = FreeCAD.Vector(
            -self.Length / 2.0 + self.ScrewLen2end,
            -self.Width / 2.0 + self.ScrewWid2end, 0)
        hole_list.append(screwface_1)
        screwface_2 = fcfun.addCyl_pos(r=self.ScrewR,
                                       h=self.ScrewL + 1,
                                       name="screwface_2",
                                       axis='z',
                                       h_disp=-self.Height / 2 - 1)
        screwface_2.Placement.Base = FreeCAD.Vector(
            self.ScrewLenSep / 2.0, -self.Width / 2.0 + self.ScrewWid2end, 0)
        hole_list.append(screwface_2)
        screwface_3 = fcfun.addCyl_pos(r=self.ScrewR,
                                       h=self.ScrewL + 1,
                                       name="screwface_3",
                                       axis='z',
                                       h_disp=-self.Height / 2 - 1)
        screwface_3.Placement.Base = FreeCAD.Vector(
            -self.Length / 2.0 + self.ScrewLen2end, self.ScrewWidSep / 2.0, 0)
        hole_list.append(screwface_3)
        screwface_4 = fcfun.addCyl_pos(r=self.ScrewR,
                                       h=self.ScrewL + 1,
                                       name="screwface_4",
                                       axis='z',
                                       h_disp=-self.Height / 2 - 1)
        screwface_4.Placement.Base = FreeCAD.Vector(self.ScrewLenSep / 2.0,
                                                    self.ScrewWidSep / 2.0, 0)
        hole_list.append(screwface_4)
        nuthouseholes = doc.addObject("Part::MultiFuse", "nuthouse_holes")
        nuthouseholes.Shapes = hole_list

        # rotation vector calculation
        if nutaxis == 'x':
            vec1 = (1, 0, 0)
        elif nutaxis == '-x':
            vec1 = (-1, 0, 0)
        elif nutaxis == 'y':
            vec1 = (0, 1, 0)
        elif nutaxis == '-y':
            vec1 = (0, -1, 0)
        elif nutaxis == 'z':
            vec1 = (0, 0, 1)
        elif nutaxis == '-z':
            vec1 = (0, 0, -1)

        if screwface_axis == 'x':
            vec2 = (1, 0, 0)
        elif screwface_axis == '-x':
            vec2 = (-1, 0, 0)
        elif screwface_axis == 'y':
            vec2 = (0, 1, 0)
        elif screwface_axis == '-y':
            vec2 = (0, -1, 0)
        elif screwface_axis == 'z':
            vec2 = (0, 0, 1)
        elif screwface_axis == '-z':
            vec2 = (0, 0, -1)

        vrot = fcfun.calc_rot(vec1, vec2)
        vdesp = fcfun.calc_desp_ncen(Length=self.Length,
                                     Width=self.Width,
                                     Height=self.Height,
                                     vec1=vec1,
                                     vec2=vec2,
                                     cx=cx,
                                     cy=cy,
                                     cz=cz)

        housing_box.Placement.Rotation = vrot
        nuthouseholes.Placement.Rotation = vrot
        housing_box.Placement.Base = vdesp
        nuthouseholes.Placement.Base = vdesp

        t8nuthouse = doc.addObject("Part::Cut", "t8nuthouse")
        t8nuthouse.Base = housing_box
        t8nuthouse.Tool = nuthouseholes

        self.fco = t8nuthouse  # the FreeCad Object
Esempio n. 4
0
                                    dent_l=h_xendslid_r.dent_l,
                                    dent_sl=h_xendslid_r.dent_sl,
                                    dlg_nx=kcomp.SEBWM16,
                                    dlg_x=kcomp.SEBWM16,
                                    dlg_ny=kcomp.SEB15A,
                                    dlg_y=kcomp.SEB15A)

h_censlid.BasePlace((0, portabase_pos_y, rod_y_pos_z))

# -------- X rods (shaft)

# the one on the front:
xrod_x_pos = -rod_y_sep / 2.0 + h_xendslid_l.slide2holdrod + TOL
xrod_f = fcfun.addCyl_pos(r=kcit.ROD_R,
                          h=kcit.ROD_X_L,
                          name="rod_x_f",
                          axis='x',
                          h_disp=xrod_x_pos)

xrod_f.Placement.Base = FreeCAD.Vector(
    0, portabase_pos_y - h_xendslid_l.holdrod_sep / 2.0, rod_y_pos_z)

xrod_b = fcfun.addCyl_pos(r=kcit.ROD_R,
                          h=kcit.ROD_X_L,
                          name="rod_x_f",
                          axis='x',
                          h_disp=xrod_x_pos)

xrod_b.Placement.Base = FreeCAD.Vector(
    0, portabase_pos_y + h_xendslid_l.holdrod_sep / 2.0, rod_y_pos_z)
Esempio n. 5
0
file_comps.write(str(2 * h_yslid_x.partheight) + ' mm \n')
file_comps.write('\n')

# -------- X rods (shafts)

# the one on the front:
rodx_pos_x = -sky_pos_x + h_yslid_x.slide2holdrod + TOL
rodx_l = -2 * rodx_pos_x

file_comps.write('# 2 Shafts, X axis, Diameter ' + str(RODX_Di))
file_comps.write('  Length: ' + str(rodx_l))
file_comps.write('\n')

rodx_ny = fcfun.addCyl_pos(r=RODX_R,
                           h=rodx_l,
                           name="rod_x_ny",
                           axis='x',
                           h_disp=rodx_pos_x)

rodx_ny.Placement.Base = FreeCAD.Vector(0, rodx_pos_ny, rodx_pos_z)

rodx_y = fcfun.addCyl_pos(r=RODX_R,
                          h=rodx_l,
                          name="rod_x_y",
                          axis='x',
                          h_disp=rodx_pos_x)

rodx_y.Placement.Base = FreeCAD.Vector(0, rodx_pos_y, rodx_pos_z)

# --------------- Central Slider, with inner hole
Esempio n. 6
0
    def __init__(self, rod_r, rod_sep, name, dent_w, dent_l, dent_sl):

        doc = FreeCAD.ActiveDocument
        self.base_place = (0, 0, 0)
        self.rod_r = rod_r
        self.rod_sep = rod_sep
        self.name = name
        self.dent_w = dent_w
        if dent_w == 0:
            self.dent_l = 0
            self.dent_sl = 0
        else:
            self.dent_l = dent_l
            self.dent_sl = dent_sl

        bearing_l = kcomp.LMEUU_L[int(2 * rod_r)]
        bearing_l_tol = bearing_l + self.TOL_BEARING_L
        bearing_d = kcomp.LMEUU_D[int(2 * rod_r)]
        bearing_d_tol = bearing_d + 2.0 * self.MLTOL
        bearing_r = bearing_d / 2.0
        bearing_r_tol = bearing_r + self.MLTOL
        #
        #    |  _____  |
        #    |_|     |_|
        #    |_       _|
        #    | |_____| | ___
        #    |_________| ___ OUT_SEP_MOVPP: separation perpendicular to movement
        #
        #    | |-----| bearing_l (+ MLTOL)
        #    |-| OUT_SEP_MOV : separacion on the direction of the movement
        #    |---------| length
        #
        # separation from the end of the linear bearing to the end
        self.OUT_SEP_MOV = 4.0
        if self.BOLT_R == 3:
            self.OUT_SEP_MOVPP = 10.0
        elif self.BOLT_R == 4:
            self.OUT_SEP_MOVPP = 10.0
        else:
            print "Bolt Size not defined in CentralSlider"

        self.length = rod_sep + 2 * bearing_r + 2 * self.OUT_SEP_MOVPP
        self.width = bearing_l + 2 * self.OUT_SEP_MOV
        self.partheight = bearing_r + self.OUT_SEP_H

        slid_x = self.width
        slid_y = self.length
        slid_z = self.partheight

        topcenslid_box = fcfun.addBox_cen(slid_x,
                                          slid_y,
                                          slid_z,
                                          "topcenslid_box",
                                          cx=True,
                                          cy=True,
                                          cz=False)
        #logger.debug('topcenslid_box %s ' % str(topcenslid_box.Shape))
        botcenslid_box = fcfun.addBox_cen(slid_x,
                                          slid_y,
                                          slid_z,
                                          "botcenslid_box",
                                          cx=True,
                                          cy=True,
                                          cz=False)
        botcenslid_box.Placement.Base = FreeCAD.Vector(0, 0, -self.partheight)

        # fillet
        topcenslid_fllt = fillet_len(box=topcenslid_box,
                                     e_len=slid_z,
                                     radius=self.FILLT_R,
                                     name="topcenslid_fllt")
        botcenslid_fllt = fillet_len(botcenslid_box, slid_z, self.FILLT_R,
                                     "botcenslid_fllt")
        # outward dent
        #               t                         y
        #           tl ___ tr  (top right)        |_ x
        #         lt  /   \  rt (right top)
        #       lb   |     | rb (right bottom) r
        #             \   /
        #        bl    --- br  (bottom right)

        # slid_x-1 because the dent was calculated with 1 mm of superposition
        # points:
        #p_dent_t  = FreeCAD.Vector(  0            , dent_l/2.0, 0)
        p_dent_tr = FreeCAD.Vector(slid_x / 2. - 1, dent_l / 2.0, 0)
        p_dent_rt = FreeCAD.Vector(slid_x / 2. - 1 + dent_w, dent_sl / 2.0, 0)
        #p_dent_r  = FreeCAD.Vector(  slid_x/2. -1 + dent_w , 0          , 0)

        dentwire = fcfun.wire_sim_xy([p_dent_tr, p_dent_rt])
        dentface = Part.Face(dentwire)
        shp_topdent = dentface.extrude(FreeCAD.Vector(0, 0, slid_z))
        shp_botdent = dentface.extrude(FreeCAD.Vector(0, 0, -slid_z))
        topdent = doc.addObject("Part::Feature", "topcenslidedent")
        topdent.Shape = shp_topdent
        botdent = doc.addObject("Part::Feature", "botcenslidedent")
        botdent.Shape = shp_botdent

        topcenslid_dent = doc.addObject("Part::Fuse", "topcenslid_dent")
        topcenslid_dent.Base = topcenslid_fllt
        topcenslid_dent.Tool = topdent

        botcenslid_dent = doc.addObject("Part::Fuse", "botcenslid_dent")
        botcenslid_dent.Base = botcenslid_fllt
        botcenslid_dent.Tool = botdent

        # list of elements to cut:
        cutlist = []

        # --------------------- Hole for the rods ---------------
        toprod = fcfun.addCyl_pos(r=rod_r + self.ROD_SPACE,
                                  h=slid_x + 2,
                                  name="toprod",
                                  axis='x',
                                  h_disp=-slid_x / 2.0 - 1)
        toprod.Placement.Base.y = rod_sep / 2.0
        cutlist.append(toprod)

        botrod = fcfun.addCyl_pos(r=rod_r + self.ROD_SPACE,
                                  h=slid_x + 2,
                                  name="botrod",
                                  axis='x',
                                  h_disp=-slid_x / 2.0 - 1)
        botrod.Placement.Base.y = -rod_sep / 2.0
        cutlist.append(botrod)

        # --------------------- Linear Bearings -------------------
        h_lmuu_0 = comps.LinBearing(r_ext=bearing_r,
                                    r_int=rod_r,
                                    h=bearing_l,
                                    name="cen_lm" + str(int(2 * rod_r)) +
                                    "uu_0",
                                    axis='x',
                                    h_disp=-bearing_l / 2.0,
                                    r_tol=self.MLTOL,
                                    h_tol=self.TOL_BEARING_L)
        h_lmuu_0.BasePlace((0, rod_sep / 2.0, 0))
        cutlist.append(h_lmuu_0.bearing_cont)

        h_lmuu_1 = comps.LinBearingClone(h_lmuu_0,
                                         "cen_lm" + str(int(2 * rod_r)) +
                                         "uu_1",
                                         namadd=0)
        h_lmuu_1.BasePlace((0, -rod_sep / 2.0, 0))
        cutlist.append(h_lmuu_1.bearing_cont)

        # ---------- Belt tensioner

        h_gt2clamp0 = beltcl.Gt2BeltClamp(base_h=slid_z,
                                          midblock=0,
                                          name="gt2clamp0")
        gt2clamp0 = h_gt2clamp0.fco  # the FreeCad Object
        #gt2clamp0.Placement.Base = FreeCAD.Vector

        # ----------- final fusion of holes
        holes = doc.addObject("Part::MultiFuse", "censlid_holes")
        holes.Shapes = cutlist

        # bearings fusion:
        bearings = doc.addObject("Part::Fuse", name + "_bear")
        bearings.Base = h_lmuu_0.bearing
        bearings.Tool = h_lmuu_1.bearing
        self.bearings = bearings

        # ----------- final cut
        top_censlid = doc.addObject("Part::Cut", name + "_top")
        top_censlid.Base = topcenslid_dent
        top_censlid.Tool = holes
        self.top_slide = top_censlid

        bot_censlid = doc.addObject("Part::Cut", name + "_bot")
        bot_censlid.Base = botcenslid_dent
        bot_censlid.Tool = holes
        self.bot_slide = bot_censlid

        doc.recompute()
Esempio n. 7
0
    def __init__(self,
                 slidrod_r,
                 holdrod_r,
                 holdrod_sep,
                 name,
                 holdrod_cen=1,
                 side='left'):

        doc = FreeCAD.ActiveDocument
        self.base_place = (0, 0, 0)
        self.slidrod_r = slidrod_r
        self.holdrod_r = holdrod_r
        self.holdrod_sep = holdrod_sep
        self.holdrod_cen = holdrod_cen

        self.name = name
        #self.axis        = axis

        # Separation from the end of the linear bearing to the end of the piece
        # on the width dimension (perpendicular to the movement)
        if self.BOLT_R == 3:
            self.OUT_SEP_W = 8.0
            # on the length dimension (parallel to the movement)
            self.OUT_SEP_L = 10.0
        elif self.BOLT_R == 4:
            self.OUT_SEP_W = 10.0
            self.OUT_SEP_L = 14.0
        else:
            print "not defined"

        bearing_l = kcomp.LMEUU_L[int(2 * slidrod_r)]
        bearing_l_tol = bearing_l + self.TOL_BEARING_L
        bearing_d = kcomp.LMEUU_D[int(2 * slidrod_r)]
        bearing_d_tol = bearing_d + 2.0 * self.MLTOL
        bearing_r = bearing_d / 2.0
        bearing_r_tol = bearing_r + self.MLTOL

        holdrod_r_tol = holdrod_r + self.MLTOL / 2.0

        holdrod_insert = self.HOLDROD_INS_RATIO * (2 * slidrod_r)

        self.slide2holdrod = bearing_r + self.MIN_BEAR_SEP
        if side == 'right' or side == 'top':
            # the distance will be negative, either on the X axis (right)
            # or on the Y axis (top)
            self.slide2holdrod_sign = -self.slide2holdrod
        else:
            self.slide2holdrod_sign = self.slide2holdrod

        # calculation of the width
        # dimensions should not depend on tolerances
        self.width = (
            bearing_d  #bearing_d_tol
            + self.OUT_SEP_W + holdrod_insert + self.MIN_BEAR_SEP)

        # calculation of the length
        # it can be determined by the holdrod_sep (separation of the hold rods)
        # or by the dimensions of the linear bearings. It will be the largest
        # of these two:
        # tlen: total length ..
        tlen_holdrod = holdrod_sep + 2 * self.OUT_SEP_L + 2 * holdrod_r
        #tlen_holdrod = holdrod_sep + 2 * self.OUT_SEP_L + 2 * holdrod_r_tol
        #tlen_bearing = (  2 * bearing_l_tol
        tlen_bearing = (2 * bearing_l + 2 * self.OUT_SEP_L + self.MIN_BEAR_SEP)
        if tlen_holdrod > tlen_bearing:
            self.length = tlen_holdrod
            print "length comes from holdrod"
        else:
            self.length = tlen_bearing
            print "length comes from bearing: Check for errors"

        self.partheight = (bearing_r + self.OUT_SEP_H)

        # distance from the center of the hold rod to the end on the sliding
        # direction
        self.holdrod2end = (self.length - holdrod_sep) / 2

        #        if axis == 'x':
        #            slid_x = self.length
        #            slid_y = self.width
        #            slid_z = self.partheight
        #        else: # 'y': default
        slid_x = self.width
        slid_y = self.length
        slid_z = self.partheight

        if holdrod_cen == 1:
            # offset if it is centered on the y
            y_offs = -slid_y / 2.0
        else:
            y_offs = 0

        slid_posx = -(bearing_r + self.OUT_SEP_W)

        bearing0_pos_y = self.OUT_SEP_L
        # Not bearing_l_tol, because the tol will be added on top and bottom
        # automatically
        bearing1_pos_y = self.length - (self.OUT_SEP_L + bearing_l)

        # adding the offset
        bearing0_pos_y = bearing0_pos_y + y_offs
        bearing1_pos_y = bearing1_pos_y + y_offs

        topslid_box = addBox(slid_x, slid_y, slid_z, "topsideslid_box")
        topslid_box.Placement.Base = FreeCAD.Vector(slid_posx, y_offs, 0)

        botslid_box = addBox(slid_x, slid_y, slid_z, "bosidetslid_box")
        botslid_box.Placement.Base = FreeCAD.Vector(slid_posx, y_offs,
                                                    -self.partheight)

        topslid_fllt = fillet_len(topslid_box, slid_z, self.FILLT_R,
                                  "topsideslid_fllt")
        botslid_fllt = fillet_len(botslid_box, slid_z, self.FILLT_R,
                                  "botsideslid_fllt")

        # list of elements that cut:
        cutlist = []

        sliderod = fcfun.addCyl_pos(r=slidrod_r + self.SLIDEROD_SPACE,
                                    h=slid_y + 2,
                                    name="sliderod",
                                    axis='y',
                                    h_disp=y_offs - 1)

        cutlist.append(sliderod)

        h_lmuu_0 = comps.LinBearing(r_ext=bearing_r,
                                    r_int=slidrod_r,
                                    h=bearing_l,
                                    name="lm" + str(int(2 * slidrod_r)) +
                                    "uu_0",
                                    axis='y',
                                    h_disp=bearing0_pos_y,
                                    r_tol=self.MLTOL,
                                    h_tol=self.TOL_BEARING_L)

        cutlist.append(h_lmuu_0.bearing_cont)

        h_lmuu_1 = comps.LinBearingClone(h_lmuu_0,
                                         "lm" + str(int(2 * slidrod_r)) +
                                         "uu_1",
                                         namadd=0)
        h_lmuu_1.BasePlace((0, bearing1_pos_y - bearing0_pos_y, 0))
        cutlist.append(h_lmuu_1.bearing_cont)

        # ------------ hold rods ----------------

        holdrod_0 = fcfun.addCyl_pos(r=holdrod_r_tol,
                                     h=holdrod_insert + 1,
                                     name="holdrod_0",
                                     axis='x',
                                     h_disp=bearing_r + self.MIN_BEAR_SEP)
        #h_disp = bearing_r_tol + self.MIN_BEAR_SEP )

        holdrod_0.Placement.Base = FreeCAD.Vector(0, self.holdrod2end + y_offs,
                                                  0)
        cutlist.append(holdrod_0)

        holdrod_1 = fcfun.addCyl_pos(r=holdrod_r_tol,
                                     h=holdrod_insert + 1,
                                     name="holdrod_1",
                                     axis='x',
                                     h_disp=bearing_r + self.MIN_BEAR_SEP)
        #h_disp = bearing_r_tol + self.MIN_BEAR_SEP )

        holdrod_1.Placement.Base = FreeCAD.Vector(
            0, self.length - self.holdrod2end + y_offs, 0)
        cutlist.append(holdrod_1)

        # -------------------- bolts and nuts
        bolt0 = addBoltNut_hole(r_shank=self.BOLT_SHANK_R_TOL,
                                l_bolt=2 * self.partheight,
                                r_head=self.BOLT_HEAD_R_TOL,
                                l_head=self.BOLT_HEAD_L,
                                r_nut=self.BOLT_NUT_R_TOL,
                                l_nut=self.BOLT_NUT_L,
                                hex_head=0,
                                extra=1,
                                supp_head=1,
                                supp_nut=1,
                                headdown=0,
                                name="bolt_hole")

        #bolt_left_pos_x =  -(  bearing_r_tol
        bolt_left_pos_x = -(bearing_r + self.OUT_SEP_W +
                            sliderod.Base.Radius.Value) / 2.0

        #bolt_right_pos_x =   (  bearing_r_tol
        bolt_right_pos_x = (bearing_r + self.MIN_BEAR_SEP +
                            0.6 * holdrod_insert)

        bolt_low_pos_y = self.OUT_SEP_L / 2.0 + y_offs
        bolt_high_pos_y = self.length - self.OUT_SEP_L / 2.0 + y_offs

        bolt_lowmid_pos_y = 1.5 * self.OUT_SEP_L + 2 * holdrod_r + y_offs
        bolt_highmid_pos_y = (
            self.length - 1.5 * self.OUT_SEP_L - 2 * holdrod_r  # no _tol
            + y_offs)

        bolt_pull_pos_x = (bearing_r_tol + self.MIN_BEAR_SEP +
                           0.25 * holdrod_insert)
        #bolt_pullow_pos_y =  2.5 * self.OUT_SEP_L + 2 * holdrod_r_tol + y_offs
        bolt_pullow_pos_y = 2.5 * self.OUT_SEP_L + 2 * holdrod_r + y_offs
        bolt_pulhigh_pos_y = (
            self.length - 2.5 * self.OUT_SEP_L - 2 * holdrod_r  # no _tol
            + y_offs)

        bolt0.Placement.Base = FreeCAD.Vector(bolt_left_pos_x,
                                              self.length / 2 + y_offs,
                                              -self.partheight)
        bolt0.Placement.Rotation = FreeCAD.Rotation(VZ, 90)
        cutlist.append(bolt0)

        # Naming convention for the bolts
        #      ______________
        #     |lu|   |   _ru_|       right up
        #     |  |   |  |____|
        #     |  |   |    rmu|       right middle up
        #     |  |   | pu    |  pulley up
        #     |0 |   | r     | right
        #     |  |   | pd    |  pulley down
        #     |  |   |   _rmd|       right middle down
        #     |  |   |  |____|
        #     |ld|___|____rd_|       right down
        #
        # Right
        boltr = Draft.clone(bolt0)
        boltr.Label = "bolt_hole_r"
        boltr.Placement.Base = FreeCAD.Vector(-bolt_left_pos_x,
                                              self.length / 2 + y_offs,
                                              -self.partheight)
        boltr.Placement.Rotation = FreeCAD.Rotation(VZ, 30)
        cutlist.append(boltr)

        # Left Up
        boltlu = Draft.clone(bolt0)
        boltlu.Label = "bolt_hole_lu"
        boltlu.Placement.Base = FreeCAD.Vector(bolt_left_pos_x, bolt_low_pos_y,
                                               -self.partheight)
        boltlu.Placement.Rotation = FreeCAD.Rotation(VZ, 0)
        cutlist.append(boltlu)

        # Left Down
        boltld = Draft.clone(bolt0)
        boltld.Label = "bolt_hole_ld"
        boltld.Placement.Base = FreeCAD.Vector(bolt_left_pos_x,
                                               bolt_high_pos_y,
                                               -self.partheight)
        boltld.Placement.Rotation = FreeCAD.Rotation(VZ, 0)
        cutlist.append(boltld)

        # Right Up
        boltru = Draft.clone(bolt0)
        boltru.Label = "bolt_hole_ru"
        boltru.Placement.Base = FreeCAD.Vector(bolt_right_pos_x,
                                               bolt_high_pos_y,
                                               -self.partheight)
        boltru.Placement.Rotation = FreeCAD.Rotation(VZ, 0)
        cutlist.append(boltru)

        # Right Down
        boltrd = Draft.clone(bolt0)
        boltrd.Label = "bolt_hole_rd"
        boltrd.Placement.Base = FreeCAD.Vector(bolt_right_pos_x,
                                               bolt_low_pos_y,
                                               -self.partheight)
        boltrd.Placement.Rotation = FreeCAD.Rotation(VZ, 0)
        cutlist.append(boltrd)

        # Right Middle Up
        boltrmu = Draft.clone(bolt0)
        boltrmu.Label = "bolt_hole_rmu"
        boltrmu.Placement.Base = FreeCAD.Vector(bolt_right_pos_x,
                                                bolt_highmid_pos_y,
                                                -self.partheight)
        boltrmu.Placement.Rotation = FreeCAD.Rotation(VZ, 0)
        cutlist.append(boltrmu)

        # Right Middle Down
        boltrmd = Draft.clone(bolt0)
        boltrmd.Label = "bolt_hole_rmd"
        boltrmd.Placement.Base = FreeCAD.Vector(bolt_right_pos_x,
                                                bolt_lowmid_pos_y,
                                                -self.partheight)
        boltrmd.Placement.Rotation = FreeCAD.Rotation(VZ, 0)
        cutlist.append(boltrmd)

        # Hole for the upper Pulley bolt
        boltpull0 = addBolt(r_shank=self.BOLTPUL_SHANK_R_TOL,
                            l_bolt=2 * self.partheight,
                            r_head=self.BOLTPUL_NUT_R_TOL,
                            l_head=self.BOLTPUL_NUT_L,
                            hex_head=1,
                            extra=1,
                            support=1,
                            headdown=1,
                            name="boltpul_hole")

        boltpull0.Placement.Base = FreeCAD.Vector(bolt_pull_pos_x,
                                                  bolt_pulhigh_pos_y,
                                                  -self.partheight)
        boltpull0.Placement.Rotation = FreeCAD.Rotation(VZ, 30)
        cutlist.append(boltpull0)

        # washers and bearings (iddle pulley), from bottom to top
        # lower washer. DIN9021 (large), size M6
        idlepull_name_list = [
            kcomp.HollowCyl(part='washer', size=6, kind='large'),
            kcomp.HollowCyl(part='washer', size=4, kind='regular'),
            kcomp.HollowCyl(part='bearing', size=624),  # 624ZZ
            kcomp.HollowCyl(part='washer', size=4, kind='regular'),
            kcomp.HollowCyl(part='washer', size=6, kind='large'),
            kcomp.HollowCyl(part='washer', size=4, kind='large')
        ]

        h_idlepull0 = partgroup.BearWashGroup(
            holcyl_list=idlepull_name_list,
            name='idlepull_0',
            normal=VZ,
            pos=boltpull0.Placement.Base +
            FreeCAD.Vector(0, 0, 2 * self.partheight))
        idlepull0 = h_idlepull0.fco

        # Hole for Pulley Down
        boltpull1 = Draft.clone(boltpull0)
        boltpull1.Label = "boltpul_hole_1"
        boltpull1.Placement.Base = FreeCAD.Vector(bolt_pull_pos_x,
                                                  bolt_pullow_pos_y,
                                                  -self.partheight)
        boltpull1.Placement.Rotation = FreeCAD.Rotation(VZ, 30)
        cutlist.append(boltpull1)

        # the other pulley:
        idlepull1 = Draft.clone(idlepull0)
        idlepull1.Label = "idlepull_1"
        idlepull1.Placement.Base.y = bolt_pullow_pos_y - bolt_pulhigh_pos_y

        idlepull_list = [idlepull0, idlepull1]
        idlepulls = doc.addObject("Part::Compound", "idlepulls")
        idlepulls.Links = idlepull_list

        # --- make a dent in the interior to save plastic
        # points: p dent

        pdent_ur = FreeCAD.Vector(self.width + slid_posx + 1,
                                  bolt_highmid_pos_y - 1, -self.partheight - 1)
        pdent_ul = FreeCAD.Vector(bolt_pull_pos_x + 1,
                                  bolt_pulhigh_pos_y - self.OUT_SEP_L,
                                  -self.partheight - 1)
        pdent_dr = FreeCAD.Vector(self.width + slid_posx + 1,
                                  bolt_lowmid_pos_y + 1, -self.partheight - 1)
        pdent_dl = FreeCAD.Vector(bolt_pull_pos_x + 1,
                                  bolt_pullow_pos_y + self.OUT_SEP_L,
                                  -self.partheight - 1)

        # dent dimensions
        self.dent_w = abs(pdent_ur.x - pdent_ul.x)  # Width
        self.dent_l = pdent_ur.y - pdent_dr.y  # Length
        self.dent_sl = pdent_ul.y - pdent_dl.y  # shorter Length

        pdent_list = [pdent_ur, pdent_ul, pdent_dl, pdent_dr]

        dent_plane = doc.addObject("Part::Polygon", "dent_plane")
        dent_plane.Nodes = pdent_list
        dent_plane.Close = True
        dent_plane.ViewObject.Visibility = False
        dent = doc.addObject("Part::Extrusion", "dent")
        dent.Base = dent_plane
        dent.Dir = (0, 0, 2 * self.partheight + 2)
        dent.Solid = True
        cutlist.append(dent)

        holes = doc.addObject("Part::MultiFuse", "holes")
        holes.Shapes = cutlist

        if side == 'right':
            holes.Placement.Rotation = FreeCAD.Rotation(VZ, 180)
            idlepulls.Placement.Rotation = FreeCAD.Rotation(VZ, 180)
            topslid_fllt.Placement.Rotation = FreeCAD.Rotation(VZ, 180)
            botslid_fllt.Placement.Rotation = FreeCAD.Rotation(VZ, 180)
            # h_lmuu_0.bearing. bearings stay the same
            if holdrod_cen == False:
                holes.Placement.Base = FreeCAD.Vector(0, self.length, 0)
                idlepulls.Placement.Base = FreeCAD.Vector(0, self.length, 0)
                topslid_fllt.Placement.Base = FreeCAD.Vector(0, self.length, 0)
                botslid_fllt.Placement.Base = FreeCAD.Vector(0, self.length, 0)
        elif side == 'bottom':
            holes.Placement.Rotation = FreeCAD.Rotation(VZ, 90)
            idlepulls.Placement.Rotation = FreeCAD.Rotation(VZ, 90)
            topslid_fllt.Placement.Rotation = FreeCAD.Rotation(VZ, 90)
            botslid_fllt.Placement.Rotation = FreeCAD.Rotation(VZ, 90)
            h_lmuu_0.bearing.Placement.Rotation = FreeCAD.Rotation(VZ, 90)
            # lmuu_1 has relative position to lmuu_0, so if rotating it
            # to the other side and reseting its position will put it in its
            # place
            if holdrod_cen == True:
                h_lmuu_1.bearing.Placement.Rotation = FreeCAD.Rotation(VZ, -90)
                h_lmuu_1.bearing.Placement.Base = FreeCAD.Vector(0, 0, 0)
            if holdrod_cen == False:
                holes.Placement.Base = FreeCAD.Vector(self.length, 0, 0)
                idlepulls.Placement.Base = FreeCAD.Vector(self.length, 0, 0)
                topslid_fllt.Placement.Base = FreeCAD.Vector(self.length, 0, 0)
                botslid_fllt.Placement.Base = FreeCAD.Vector(self.length, 0, 0)
                h_lmuu_0.bearing.Placement.Base = FreeCAD.Vector(
                    self.length, 0, 0)
                h_lmuu_1.bearing.Placement.Base = FreeCAD.Vector(
                    self.length - h_lmuu_1.bearing.Placement.Base.y, 0, 0)
                h_lmuu_1.bearing.Placement.Rotation = FreeCAD.Rotation(VZ, 90)
        elif side == 'top':
            holes.Placement.Rotation = FreeCAD.Rotation(VZ, -90)
            idlepulls.Placement.Rotation = FreeCAD.Rotation(VZ, -90)
            topslid_fllt.Placement.Rotation = FreeCAD.Rotation(VZ, -90)
            botslid_fllt.Placement.Rotation = FreeCAD.Rotation(VZ, -90)
            h_lmuu_0.bearing.Placement.Rotation = FreeCAD.Rotation(VZ, -90)
            # lmuu_1 has relative position to lmuu_0, so if rotating it
            # to the other side and reseting its position will put it in its
            # place
            if holdrod_cen == True:
                h_lmuu_1.bearing.Placement.Rotation = FreeCAD.Rotation(VZ, 90)
                h_lmuu_1.bearing.Placement.Base = FreeCAD.Vector(0, 0, 0)
            if holdrod_cen == False:
                #holes.Placement.Base = FreeCAD.Vector (self.length,0,0)
                #topslid_fllt.Placement.Base = FreeCAD.Vector (self.length,0,0)
                #botslid_fllt.Placement.Base = FreeCAD.Vector (self.length,0,0)
                #h_lmuu_0.bearing.Placement.Base = FreeCAD.Vector (
                #self.length,0,0)
                h_lmuu_1.bearing.Placement.Base = FreeCAD.Vector(
                    h_lmuu_1.bearing.Placement.Base.y, 0, 0)
                h_lmuu_1.bearing.Placement.Rotation = FreeCAD.Rotation(VZ, -90)

        # elif side == 'left':
        # don't do anything, default condition

        self.idlepulls = idlepulls

        bearings = doc.addObject("Part::Fuse", name + "_bear")
        bearings.Base = h_lmuu_0.bearing
        bearings.Tool = h_lmuu_1.bearing
        self.bearings = bearings

        top_slide = doc.addObject("Part::Cut", name + "_top")
        top_slide.Base = topslid_fllt
        top_slide.Tool = holes
        self.top_slide = top_slide

        bot_slide = doc.addObject("Part::Cut", name + "_bot")
        bot_slide.Base = botslid_fllt
        bot_slide.Tool = holes
        self.bot_slide = bot_slide
Esempio n. 8
0
framex_11.Label = 'framex_11'
framex_11.Placement.Base = FreeCAD.Vector(  0, # already centered
                                            frame_posy,
                                            FRAME_H-FRAM_RBAR_W/2.)
frame_list.append (framex_11)

frame = doc.addObject("Part::Compound", "frame")
frame.Links = frame_list


# --------------- Y Rods  ---------------------------

# os: translate([-77, 75, 15]) rotate([90, 0, 0])
#                cylinder(r = 1, h = 150, $fn = 100);
rody_00 = fcfun.addCyl_pos (r = RODY_R, h= framey_l, name='rody_00',
                            axis = 'y',
                            h_disp =  -(frame_posy-FRAM_RBAR_W/2.))

# the y position is already set
rody_00.Placement.Base = FreeCAD.Vector (- frame_posx, 0, B_RODY_H)

# os: translate([77, 75, 15]) rotate([90, 0, 0])
#                cylinder(r = 1, h = 150, $fn = 100);
rody_10 = Draft.clone(rody_00)
rody_10.Label = 'rody_10'
rody_10.Placement.Base = FreeCAD.Vector( frame_posx, 0, B_RODY_H)

# os: translate([-77, 75, 90]) rotate([90, 0, 0])
#                cylinder(r = 1, h = 150, $fn = 100);
rody_01 = Draft.clone(rody_00)
rody_01.Label = 'rody_01'