def __init__(self, size, length, shaft_l, circle_r, circle_h, name="nemamotor", chmf=1, rshaft_l=0, bolt_depth=3, bolt_out=2, container=1, normal=VZ, pos=V0): doc = FreeCAD.ActiveDocument self.base_place = (0, 0, 0) self.size = size self.width = kcomp.NEMA_W[size] self.length = length self.shaft_l = shaft_l self.circle_r = circle_r self.circle_h = circle_h self.chmf = chmf self.rshaft_l = rshaft_l self.bolt_depth = bolt_depth self.bolt_out = bolt_out self.container = container nnormal = DraftVecUtils.scaleTo(normal, 1) self.normal = nnormal self.pos = pos nemabolt_d = kcomp.NEMA_BOLT_D[size] self.nemabolt_d = nemabolt_d mtol = kcomp.TOL - 0.1 lnormal = DraftVecUtils.scaleTo(nnormal, length) neg_lnormal = DraftVecUtils.neg(lnormal) # motor shape v1 = FreeCAD.Vector(self.width / 2. - chmf, self.width / 2., 0) v2 = FreeCAD.Vector(self.width / 2., self.width / 2. - chmf, 0) motorwire = fcfun.wire_sim_xy([v1, v2]) # motor wire normal is VZ # DraftVecUtils doesnt work as well # rot = DraftVecUtils.getRotation(VZ, nnormal) # the order matter VZ, nnormal. It seems it doent matter VZ or VZN # this is valid: #rot = DraftGeomUtils.getRotation(VZ,nnormal) #print rot rot = FreeCAD.Rotation(VZ, nnormal) print rot motorwire.Placement.Rotation = rot motorwire.Placement.Base = pos motorface = Part.Face(motorwire) shp_motorbox = motorface.extrude(neg_lnormal) # shaft shape if rshaft_l == 0: # no rear shaft shp_shaft = fcfun.shp_cyl(r=kcomp.NEMA_SHAFT_D[size] / 2., h=shaft_l, normal=nnormal, pos=pos) else: rshaft_posend = DraftVecUtils.scaleTo(neg_lnormal, rshaft_l + length) shp_shaft = fcfun.shp_cyl(r=kcomp.NEMA_SHAFT_D[size] / 2., h=shaft_l + rshaft_l + length, normal=nnormal, pos=pos + rshaft_posend) shp_motorshaft = shp_motorbox.fuse(shp_shaft) # Bolt holes # AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA # There is something wrong with the position of these bolts # bhole00_pos = FreeCAD.Vector(-kcomp.NEMA_BOLT_SEP[size]/2, # -kcomp.NEMA_BOLT_SEP[size]/2, # -bolt_depth) + pos # bhole01_pos = FreeCAD.Vector(-kcomp.NEMA_BOLT_SEP[size]/2, # kcomp.NEMA_BOLT_SEP[size]/2, # -bolt_depth) + pos # bhole10_pos = FreeCAD.Vector( kcomp.NEMA_BOLT_SEP[size]/2, # -kcomp.NEMA_BOLT_SEP[size]/2, # -bolt_depth) + pos # bhole11_pos = FreeCAD.Vector( kcomp.NEMA_BOLT_SEP[size]/2, # kcomp.NEMA_BOLT_SEP[size]/2, # -bolt_depth) + pos # bhole00_posrot = DraftVecUtils.rotate(bhole00_pos, rot.Angle, rot.Axis) # bhole01_posrot = DraftVecUtils.rotate(bhole01_pos, rot.Angle, rot.Axis) # bhole10_posrot = DraftVecUtils.rotate(bhole10_pos, rot.Angle, rot.Axis) # bhole11_posrot = DraftVecUtils.rotate(bhole11_pos, rot.Angle, rot.Axis) # shp_bolt00 = fcfun.shp_cyl ( # r=kcomp.NEMA_BOLT_D[size]/2.+kcomp.TOL/2., # h=bolt_depth + shaft_l, # normal = nnormal, # pos= bhole00_posrot) # shp_bolt01 = fcfun.shp_cyl ( # r=kcomp.NEMA_BOLT_D[size]/2.+kcomp.TOL/2., # h=bolt_depth + shaft_l, # normal = nnormal, # pos= bhole01_posrot) # shp_bolt10 = fcfun.shp_cyl ( # r=kcomp.NEMA_BOLT_D[size]/2.+kcomp.TOL/2., # h=bolt_depth + shaft_l, # normal = nnormal, # pos= bhole10_posrot) # shp_bolt11 = fcfun.shp_cyl ( # r=kcomp.NEMA_BOLT_D[size]/2.+kcomp.TOL/2., # h=bolt_depth + shaft_l, # normal = nnormal, # pos= bhole11_posrot) # shp_bolts = shp_bolt00.multiFuse([shp_bolt01, shp_bolt10, shp_bolt11]) # list of shapes to make a fusion of the container shp_contfuselist = [] # shp_contfuselist.append(shp_bolts) b2hole00_pos = FreeCAD.Vector(-kcomp.NEMA_BOLT_SEP[size] / 2, -kcomp.NEMA_BOLT_SEP[size] / 2, -bolt_depth) b2hole01_pos = FreeCAD.Vector(-kcomp.NEMA_BOLT_SEP[size] / 2, kcomp.NEMA_BOLT_SEP[size] / 2, -bolt_depth) b2hole10_pos = FreeCAD.Vector(kcomp.NEMA_BOLT_SEP[size] / 2, -kcomp.NEMA_BOLT_SEP[size] / 2, -bolt_depth) b2hole11_pos = FreeCAD.Vector(kcomp.NEMA_BOLT_SEP[size] / 2, kcomp.NEMA_BOLT_SEP[size] / 2, -bolt_depth) b2hole00 = addBolt(r_shank=nemabolt_d / 2. + mtol / 2., l_bolt=bolt_out + bolt_depth, r_head=kcomp.D912_HEAD_D[nemabolt_d] / 2. + mtol / 2., l_head=kcomp.D912_HEAD_L[nemabolt_d] + mtol, hex_head=0, extra=1, support=1, headdown=0, name="b2hole00") b2hole01 = Draft.clone(b2hole00) b2hole01.Label = "b2hole01" b2hole10 = Draft.clone(b2hole00) b2hole10.Label = "b2hole10" b2hole11 = Draft.clone(b2hole00) b2hole11.Label = "b2hole11" b2hole00.ViewObject.Visibility = False b2hole01.ViewObject.Visibility = False b2hole10.ViewObject.Visibility = False b2hole11.ViewObject.Visibility = False b2hole00.Placement.Base = b2hole00_pos b2hole01.Placement.Base = b2hole01_pos b2hole10.Placement.Base = b2hole10_pos b2hole11.Placement.Base = b2hole11_pos # it doesnt work if dont recompute here! probably the clones doc.recompute() b2holes_list = [b2hole00, b2hole01, b2hole10, b2hole11] # not an efficient way, either use shapes or fco, but not both shp_b2holes = b2hole00.Shape.multiFuse( [b2hole01.Shape, b2hole10.Shape, b2hole11.Shape]) #Part.show(shp_b2holes) b2holes = doc.addObject("Part::MultiFuse", "b2holes") b2holes.Shapes = b2holes_list b2holes.ViewObject.Visibility = False shp_b2holes.Placement.Base = pos shp_b2holes.Placement.Rotation = rot shp_contfuselist.append(shp_b2holes) # Circle on the base of the shaft if circle_r == 0: calcircle_r = kcomp.NEMA_BOLT_SEP[size] / 2. else: calcircle_r = circle_r if circle_h != 0: shp_circle = fcfun.shp_cyl( r=calcircle_r, h=circle_h + 1, #supperposition for union normal=nnormal, #supperposition for union pos=pos - nnormal) # fmotor: fused motor shp_fmotor = shp_motorshaft.fuse(shp_circle) else: shp_fmotor = shp_motorshaft #fmotor = doc.addObject("Part::Feature", "fmotor") #fmotor.Shape = shp_fmotor #shp_motor = shp_fmotor.cut(shp_bolts) shp_motor = shp_fmotor.cut(shp_b2holes) #Part.show(shp_bolts) # container if container == 1: # 2*TOL to make sure it fits v1 = FreeCAD.Vector(self.width / 2. - chmf / 2. + 2 * kcomp.TOL, self.width / 2. + 2 * kcomp.TOL, 0) v2 = FreeCAD.Vector(self.width / 2. + 2 * kcomp.TOL, self.width / 2. - chmf / 2. + 2 * kcomp.TOL, 0) cont_motorwire = fcfun.wire_sim_xy([v1, v2]) cont_motorwire.Placement.Rotation = rot cont_motorwire.Placement.Base = pos cont_motorface = Part.Face(cont_motorwire) shp_contmotor_box = cont_motorface.extrude(neg_lnormal) # the container is much wider than the shaft if rshaft_l == 0: # no rear shaft shp_contshaft = fcfun.shp_cyl(r=calcircle_r + kcomp.TOL, h=shaft_l + 1, normal=nnormal, pos=pos - nnormal) else: shp_contshaft = fcfun.shp_cyl(r=calcircle_r + kcomp.TOL, h=shaft_l + rshaft_l + length, normal=nnormal, pos=pos + rshaft_posend) shp_contfuselist.append(shp_contshaft) shp_contmotor = shp_contmotor_box.multiFuse(shp_contfuselist) else: shp_contmotor = shp_motor # we put the same shape doc.recompute() #fco_motor = doc.addObject("Part::Cut", name) #fco_motor.Base = fmotor #fco_motor.Tool = b2holes fco_motor = doc.addObject("Part::Feature", name) fco_motor.Shape = shp_motor self.fco = fco_motor self.shp_cont = shp_contmotor #Part.show(shp_contmotor) doc.recompute()
def __init__(self, base_h, midblock, name): doc = FreeCAD.ActiveDocument self.base_place = (0,0,0) # Clamp base self.CBASE_H = base_h # divides how much is rail and how much is wall # It has to be greater than 1. If it is 1, there is no wall. # if it is 2. Half is wall, half is indent self.CBASE_RAIL_DIV = 1.6 #2.0 self.CBASE_RAIL = self.CBASE_H / self.CBASE_RAIL_DIV # rail for the base # the part that is wall, divided by 2, because one goes at the bottom # and the other on top # rail for the base self.CBASE_WALL = (self.CBASE_H - self.CBASE_RAIL)/2.0 # Indentation, if midblock == 0, the Indentation is negative, which # means it will be outward, otherwise, inward self.CBASERAILIND = self.CBASE_RAIL/3.0 self.midblock = midblock # Width of the interior/middle clamp blocks self.CB_MW = midblock * self.CB_W if midblock == 0: self.CBASE_W = self.CB_IW + 2 * self.CB_W self.CBASERAILIND_SIG = - self.CBASERAILIND # Since the indentation is outwards, we have to add it self.TotW = self.CBASE_W + 2 * self.CBASERAILIND # external indent, so all the internal elements have to have this # nternal offset. In Y axis self.extind = self.CBASERAILIND else: self.CBASE_W = 2 * self.CB_IW + 2 * self.CB_W + self.CB_MW self.CBASERAILIND_SIG = self.CBASERAILIND # Since the indentation is inward, it is just the base self.TotW = self.CBASE_W # no external indent, so the internal elements don't have to have # this internal offset self.extind = 0 gt2_clamp_list = [] # we make it using points-plane and extrusions #gt2_base =addBox (self.CBASE_L, self.CBASE_W, self.CBASE_H, "gt2_base") gt2_cb_1 = addBox (self.CB_L, self.CB_W, self.C_H+1, name + "_cb1") gt2_cb_1.Placement.Base = FreeCAD.Vector (self.CBASE_L-self.CB_L, self.extind, self.CBASE_H-1) gt2_clamp_list.append (gt2_cb_1) if midblock > 0: gt2_cb_2 = addBox (self.CB_L, self.CB_MW, self.C_H+1, name + "_cb2") gt2_cb_2.Placement.Base = FreeCAD.Vector (self.CBASE_L-self.CB_L, self.CB_W + self.CB_IW + self.extind, self.CBASE_H-1) gt2_clamp_list.append (gt2_cb_2) gt2_cb_3 = addBox (self.CB_L, self.CB_W, self.C_H + 1, name + "_cb3") gt2_cb_3.Placement.Base = FreeCAD.Vector (self.CBASE_L-self.CB_L, self.CBASE_W - self.CB_W + self.extind, self.CBASE_H-1) gt2_clamp_list.append (gt2_cb_3) gt2_cyl = addCyl (self.CCYL_R, self.C_H + 1, name + "_cyl") gt2_cyl.Placement.Base = FreeCAD.Vector (self.CCYL_R, self.CBASE_W/2 + self.extind, self.CBASE_H-1) gt2_clamp_list.append (gt2_cyl) # base # calling to the method that gets a list of the points to make # the polygon of the base #gt2_base_list = self.get_base_list_v() # doing this because the carriage is already printed, so I am going # to make the base smaller to fit. CHANGE to the upper sentence gt2_base_list = self.get_base_list_v(offs_y = -TOL/2, offs_z = - TOL) """ gt2_base_plane_yz = Part.makePolygon(gt2_base_list) gt2_base = gt2_base_plane_xy.extrude(FreeCAD.Vector(self.CBASE_L,0,0)) """ gt2_base_plane_yz = doc.addObject("Part::Polygon", name + "base_plane_yz") gt2_base_plane_yz.Nodes = gt2_base_list gt2_base_plane_yz.Close = True gt2_base = doc.addObject("Part::Extrusion", name + "extr_base") gt2_base.Base = gt2_base_plane_yz gt2_base.Dir = (self.CBASE_L,0,0) gt2_base.Solid = True gt2_clamp_list.append(gt2_base) gt2_clamp_basic = doc.addObject("Part::MultiFuse", name + "clamp_base") gt2_clamp_basic.Shapes = gt2_clamp_list # creation of the same base, but with a little offset to be able to # cut the piece where it will be inserted #gt2_baseof_list = self.get_base_list_v(offs_y = TOL, offs_z = TOL/2.0) # CHANGE TO THE UPPER SENTENCE gt2_baseof_list = self.get_base_list_v(offs_y = TOL, offs_z = 0) gt2_baseof_plane_yz = doc.addObject("Part::Polygon", name + "_baseof_plane_yz") gt2_baseof_plane_yz.Nodes = gt2_baseof_list gt2_baseof_plane_yz.Close = True gt2_baseof = doc.addObject("Part::Extrusion", name + "_baseof") gt2_baseof.Base = gt2_baseof_plane_yz gt2_baseof.Dir = (self.CBASE_L,0,0) gt2_baseof.Solid = True self.fco_cont = gt2_baseof # hole for the leadscrew bolt # the head is longer because it can be inserted deeper into the piece # so a shorter bolt will be needed gt2_base_lscrew = addBolt (kcomp.M3_SHANK_R_TOL, self.CBASE_L, kcomp.M3_HEAD_R_TOL, 2.5*kcomp.M3_HEAD_L, extra = 1, support = 0, name= name + "_base_lscrew") gt2_base_lscrew.Placement.Base = FreeCAD.Vector (self.CBASE_L, self.CBASE_W/2.0 + self.extind, self.CBASE_H/2.0) gt2_base_lscrew.Placement.Rotation = FreeCAD.Rotation (VY, -90) # ------------ hole for a nut, also M3, for the leadscrew gt2_base_lscrew_nut = doc.addObject("Part::Prism", name + "_base_lscrew_nut") gt2_base_lscrew_nut.Polygon = 6 gt2_base_lscrew_nut.Circumradius = kcomp.M3_NUT_R_TOL gt2_base_lscrew_nut.Height = kcomp.M3NUT_HOLE_H gt2_base_lscrew_nut.Placement.Rotation = \ gt2_base_lscrew.Placement.Rotation # + TOL so it will be a little bit higher, so more room gt2_base_lscrew_nut.Placement.Base = FreeCAD.Vector ( #(self.CBASE_L-kcomp.M3_HEAD_L)/2.0 - kcomp.M3NUT_HOLE_H/2.0, self.NUT_HOLE_EDGSEP, self.CBASE_W/2.0 + self.extind, self.CBASE_H/2.0 + TOL) gt2_base_lscrew_nut.Placement.Rotation = FreeCAD.Rotation (VY, 90) # ------------ hole to reach out the nut hole # X is the length: M3NUT_HOLE_H. Y is the width. M3_2APOT_TOL gt2_base_lscrew_nut2 = addBox (kcomp.M3NUT_HOLE_H, kcomp.M3_2APOT_TOL, self.CBASE_H/2.0 + TOL, name + "_base_lscrew_nut2") gt2_base_lscrew_nut2.Placement.Base = ( #((self.CBASE_L-kcomp.M3_HEAD_L) - kcomp.M3NUT_HOLE_H)/2.0, self.NUT_HOLE_EDGSEP, (self.CBASE_W - kcomp.M3_2APOT_TOL)/2.0 + self.extind, 0) gt2_base_holes_l = [ gt2_base_lscrew, gt2_base_lscrew_nut, gt2_base_lscrew_nut2] # fuse the holes gt2_clamp_holes = doc.addObject("Part::MultiFuse", name + "_clamp_hole") gt2_clamp_holes.Shapes = gt2_base_holes_l # Substract the holes gt2_clamp = doc.addObject("Part::Cut", name) gt2_clamp.Base = gt2_clamp_basic gt2_clamp.Tool = gt2_clamp_holes self.fco = gt2_clamp # the FreeCad Object
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