def __init__(self, nema_size=17, base_motor_d=6., base_d=4., base_h=16., wall_thick=4., motor_thick=4., reinf_thick=4., motor_min_h=10., motor_max_h=20., motor_xtr_space=2., bolt_wall_d=4., bolt1_wall_d=5., bolt_wall_sep=30., chmf_r=1., opt_sides=1, axis_h=VZ, axis_d=VX, axis_w=None, pos_h=1, pos_d=3, pos_w=0, pos=V0, name=''): if axis_w is None or axis_w == V0: axis_w = axis_h.cross(axis_d) #vector product default_name = 'base' self.set_name(name, default_name, change=0) Obj3D.__init__(self, axis_d, axis_w, axis_h, self.name) # save the arguments as attributes: frame = inspect.currentframe() args, _, _, values = inspect.getargvalues(frame) for i in args: if not hasattr(self, i): setattr(self, i, values[i]) self.pos = FreeCAD.Vector(0, 0, 0) self.position = pos # normal axes to print without support self.prnt_ax = self.axis_h self.motor_w = kcomp.NEMA_W[nema_size] self.motor_bolt_sep = kcomp.NEMA_BOLT_SEP[nema_size] self.motor_bolt_d = kcomp.NEMA_BOLT_D[nema_size] self.base_motor_h = motor_thick + motor_max_h + 2 * bolt_wall_d + 30. # calculation of the bolt to hold the base to the profile self.boltshank_r_tol = kcomp.D912[bolt1_wall_d]['shank_r_tol'] self.bolthead_r = kcomp.D912[bolt1_wall_d]['head_l'] self.bolthead_r_tol = kcomp.D912[bolt1_wall_d]['head_r'] self.bolthead_l = kcomp.D912[bolt1_wall_d]['head_l'] # calculation of the bolt wall d self.boltwallshank_r_tol = kcomp.D912[bolt_wall_d]['shank_r_tol'] self.boltwallhead_l = kcomp.D912[bolt_wall_d]['head_l'] self.boltwallhead_r = kcomp.D912[bolt_wall_d]['head_r'] self.washer_thick = kcomp.WASH_D125_T[bolt_wall_d] # calculation of the bolt wall separation self.max_bolt_wall_sep = self.motor_w - 2 * self.boltwallhead_r if bolt_wall_sep == 0: self.bolt_wall_sep = self.max_bolt_wall_sep elif bolt_wall_sep > self.max_bolt_wall_sep: logger.debug('bolt separation too large:' + str(bolt_wall_sep)) self.bolt_wall_sep = self.max_bolt_wall_sep logger.debug('taking largest value:' + str(self.bolt_wall_sep)) elif bolt_wall_sep < 4 * self.boltwallhead_r: logger.debug('bolt separation too short:' + str(bolt_wall_sep)) self.bolt_wall_sep = self.self.max_bolt_wall_sep logger.debug('taking smallest value:' + str(self.bolt_wall_sep)) # distance from the motor to the inner wall (in axis_d) self.motor_inwall_space = motor_xtr_space + self.boltwallhead_l + self.washer_thick # making the big box that will contain everything and will be cut self.tot_h = wall_thick + base_h + self.base_motor_h self.tot_d = base_d + 2 * self.bolthead_r if opt_sides == 0: self.tot_w = 2 * reinf_thick + self.motor_w + 2 * motor_xtr_space else: self.tot_w = 2 * reinf_thick + self.motor_w + 2 * motor_xtr_space + 4 * self.bolthead_r_tol + 8. # definition of which axis is symmetrical self.h0_cen = 0 self.w0_cen = 1 # symmetrical self.d0_cen = 0 # vectors from the origin to the points along axis_h self.h_o[0] = V0 self.h_o[1] = self.vec_h(wall_thick) self.h_o[2] = self.vec_h(wall_thick + 2 * self.bolthead_r) self.h_o[3] = self.vec_h(wall_thick + base_h) self.h_o[4] = self.vec_h(wall_thick + base_h + motor_thick) self.h_o[5] = self.vec_h(wall_thick + base_h + motor_thick + motor_min_h) self.h_o[6] = self.vec_h(wall_thick + base_h + motor_thick) self.h_o[7] = self.vec_h(wall_thick + base_h + motor_thick + (motor_min_h + motor_max_h) / 4.) self.h_o[8] = self.vec_h(wall_thick + base_h + motor_thick + 2 * (motor_min_h + motor_max_h) / 4.) self.h_o[9] = self.vec_h(wall_thick + base_h + motor_thick + 3 * (motor_min_h + motor_max_h) / 4.) self.h_o[10] = self.vec_h(wall_thick + base_h + motor_thick + (motor_min_h + motor_max_h)) self.h_o[11] = self.vec_h(wall_thick + base_h + motor_thick + 5 * (motor_min_h + motor_max_h) / 4.) self.h_o[12] = self.vec_h(wall_thick + base_h + motor_thick + motor_max_h) self.h_o[13] = self.vec_h(self.tot_h) # position along axis_d self.d_o[0] = V0 self.d_o[1] = self.vec_d(base_d) self.d_o[2] = self.vec_d(base_motor_d) self.d_o[3] = self.vec_d(self.tot_d / 2.) self.d_o[4] = self.vec_d(base_d + self.bolthead_r_tol) self.d_o[5] = self.vec_d(self.tot_d) # vectors from the origin to the points along axis_w if opt_sides == 0: self.w_o[0] = V0 self.w_o[1] = self.vec_w(-self.bolt_wall_sep / 2.) self.w_o[2] = self.vec_w(-self.motor_bolt_sep / 2.) self.w_o[3] = self.vec_w(-self.tot_w / 2.) else: self.w_o[0] = V0 self.w_o[1] = self.vec_w(-self.bolt_wall_sep / 2.) self.w_o[2] = self.vec_w(-self.motor_bolt_sep / 2.) self.w_o[3] = self.vec_w( -(2 * reinf_thick + self.motor_w + 2 * motor_xtr_space) / 2.) self.w_o[4] = self.vec_w( -(2 * reinf_thick + self.motor_w + 2 * motor_xtr_space + 2 * self.bolthead_r_tol + 4.) / 2.) self.w_o[5] = self.vec_w(-self.tot_w / 2.) # calculates the position of the origin, and keeps it in attribute pos_o self.set_pos_o() # make the whole box if opt_sides == 0: shp_box = fcfun.shp_box_dir(box_w=self.tot_w, box_d=self.tot_d, box_h=self.tot_h, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=0, ch=0, pos=self.pos_o) super().add_child(shp_box, 1, 'shp_box') shp_box_int = fcfun.shp_box_dir(box_w=self.tot_w, box_d=self.tot_d, box_h=base_h, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=0, ch=0, pos=self.get_pos_dwh(1, 0, 1)) super().add_child(shp_box_int, 0, 'shp_box_int') shp_box_ext = fcfun.shp_box_dir(box_w=self.tot_w, box_d=self.tot_d, box_h=self.base_motor_h, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=0, ch=0, pos=self.get_pos_dwh(2, 0, 3)) super().add_child(shp_box_ext, 0, 'shp_box_ext') shp_box_init = fcfun.shp_box_dir(box_w=self.tot_w + 2 * self.bolthead_r_tol, box_d=self.tot_d, box_h=wall_thick, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=0, ch=0, pos=self.get_pos_dwh(5, 0, 0)) super().add_child(shp_box_init, 0, 'shp_box_init') # holes to hold the profile shp_hole1 = fcfun.shp_cylcenxtr(r=self.boltshank_r_tol, h=wall_thick, normal=self.axis_h, ch=0, xtr_top=1, xtr_bot=1, pos=self.get_pos_dwh(4, -2, 0)) super().add_child(shp_hole1, 0, 'shp_hole1') shp_hole2 = fcfun.shp_cylcenxtr(r=self.boltshank_r_tol, h=wall_thick, normal=self.axis_h, ch=0, xtr_top=1, xtr_bot=1, pos=self.get_pos_dwh(4, 2, 0)) super().add_child(shp_hole2, 0, 'shp_hole2') # holes to hold the Nema Motor Holder shp_cen_bolt1 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, -1, 6)) super().add_child(shp_cen_bolt1, 0, 'shp_cen_bolt1') shp_cen_bolt2 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, 1, 6)) super().add_child(shp_cen_bolt2, 0, 'shp_cen_bolt2') shp_cen_bolt3 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, -1, 7)) super().add_child(shp_cen_bolt3, 0, 'shp_cen_bolt3') shp_cen_bolt4 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, 1, 7)) super().add_child(shp_cen_bolt4, 0, 'shp_cen_bolt4') shp_cen_bolt5 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, -1, 8)) super().add_child(shp_cen_bolt5, 0, 'shp_cen_bolt5') shp_cen_bolt6 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, 1, 8)) super().add_child(shp_cen_bolt6, 0, 'shp_cen_bolt6') shp_cen_bolt7 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, -1, 9)) super().add_child(shp_cen_bolt7, 0, 'shp_cen_bolt7') shp_cen_bolt8 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, 1, 9)) super().add_child(shp_cen_bolt8, 0, 'shp_cen_bolt8') shp_cen_bolt9 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, -1, 10)) super().add_child(shp_cen_bolt9, 0, 'shp_cen_bolt9') shp_cen_bolt10 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, 1, 10)) super().add_child(shp_cen_bolt10, 0, 'shp_cen_bolt10') shp_cen_bolt11 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, -1, 11)) super().add_child(shp_cen_bolt11, 0, 'shp_cen_bolt11') shp_cen_bolt12 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, 1, 11)) super().add_child(shp_cen_bolt12, 0, 'shp_cen_bolt12') else: shp_box = fcfun.shp_box_dir(box_w=self.tot_w, box_d=self.tot_d, box_h=self.tot_h, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=0, ch=0, pos=self.pos_o) super().add_child(shp_box, 1, 'shp_box') shp_box_int = fcfun.shp_box_dir(box_w=self.tot_w, box_d=self.tot_d, box_h=base_h, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=0, ch=0, pos=self.get_pos_dwh(1, 0, 1)) super().add_child(shp_box_int, 0, 'shp_box_int') shp_box_ext = fcfun.shp_box_dir(box_w=self.tot_w, box_d=self.tot_d, box_h=self.base_motor_h, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=0, ch=0, pos=self.get_pos_dwh(2, 0, 3)) super().add_child(shp_box_ext, 0, 'shp_box_ext') shp_box_init = fcfun.shp_box_dir(box_w=self.tot_w, box_d=self.tot_d, box_h=wall_thick, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=0, ch=0, pos=self.get_pos_dwh(5, 0, 0)) super().add_child(shp_box_init, 0, 'shp_box_init') shp_box_lat1 = fcfun.shp_box_dir(box_w=2 * +self.bolthead_r_tol + 4., box_d=self.tot_d, box_h=self.tot_h, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=0, ch=0, pos=self.get_pos_dwh(0, -4, 1)) super().add_child(shp_box_lat1, 0, 'shp_box_lat1') shp_box_lat2 = fcfun.shp_box_dir(box_w=2 * +self.bolthead_r_tol + 4., box_d=self.tot_d, box_h=self.tot_h, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=0, ch=0, pos=self.get_pos_dwh(0, 4, 1)) super().add_child(shp_box_lat2, 0, 'shp_box_lat2') # holes to hold the profile # self.get_d_ab(5,4).x shp_hole1 = fcfun.shp_stadium_dir( self.tot_d - 2 * ((self.d_o[5] - self.d_o[4]).Length), radius=self.boltshank_r_tol, height=wall_thick, fc_axis_h=self.axis_h, fc_axis_l=self.axis_d.negative(), fc_axis_s=V0, ref_l=2, ref_s=1, ref_h=2, xtr_nh=1, pos=self.get_pos_dwh(4, -4, 0)) super().add_child(shp_hole1, 0, 'shp_hole1') shp_hole2 = fcfun.shp_stadium_dir( self.tot_d - 2 * ((self.d_o[5] - self.d_o[4]).Length), radius=self.boltshank_r_tol, height=wall_thick, fc_axis_h=self.axis_h, fc_axis_l=self.axis_d.negative(), fc_axis_s=V0, ref_l=2, ref_s=1, ref_h=2, xtr_nh=1, pos=self.get_pos_dwh(4, 4, 0)) super().add_child(shp_hole2, 0, 'shp_hole2') shp_hole3 = fcfun.shp_cylcenxtr(r=self.boltshank_r_tol, h=wall_thick, normal=self.axis_h, ch=0, xtr_top=1, xtr_bot=1, pos=self.get_pos_dwh(4, -2, 0)) super().add_child(shp_hole3, 0, 'shp_hole3') shp_hole4 = fcfun.shp_cylcenxtr(r=self.boltshank_r_tol, h=wall_thick, normal=self.axis_h, ch=0, xtr_top=1, xtr_bot=1, pos=self.get_pos_dwh(4, 2, 0)) super().add_child(shp_hole4, 0, 'shp_hole4') # holes to hold the Nema Motor Holder shp_cen_bolt1 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, -1, 6)) super().add_child(shp_cen_bolt1, 0, 'shp_cen_bolt1') shp_cen_bolt2 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, 1, 6)) super().add_child(shp_cen_bolt2, 0, 'shp_cen_bolt2') shp_cen_bolt3 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, -1, 7)) super().add_child(shp_cen_bolt3, 0, 'shp_cen_bolt3') shp_cen_bolt4 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, 1, 7)) super().add_child(shp_cen_bolt4, 0, 'shp_cen_bolt4') shp_cen_bolt5 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, -1, 8)) super().add_child(shp_cen_bolt5, 0, 'shp_cen_bolt5') shp_cen_bolt6 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, 1, 8)) super().add_child(shp_cen_bolt6, 0, 'shp_cen_bolt6') shp_cen_bolt7 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, -1, 9)) super().add_child(shp_cen_bolt7, 0, 'shp_cen_bolt7') shp_cen_bolt8 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, 1, 9)) super().add_child(shp_cen_bolt8, 0, 'shp_cen_bolt8') shp_cen_bolt9 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, -1, 10)) super().add_child(shp_cen_bolt9, 0, 'shp_cen_bolt9') shp_cen_bolt10 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, 1, 10)) super().add_child(shp_cen_bolt10, 0, 'shp_cen_bolt10') shp_cen_bolt11 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, -1, 11)) super().add_child(shp_cen_bolt11, 0, 'shp_cen_bolt11') shp_cen_bolt12 = fcfun.shp_bolt_dir( r_shank=self.boltwallshank_r_tol, l_bolt=base_motor_d, r_head=self.boltwallhead_r, l_head=self.boltwallhead_l, xtr_head=1, xtr_shank=1, fc_normal=self.axis_d, pos_n=0, pos=self.get_pos_dwh(0, 1, 11)) super().add_child(shp_cen_bolt12, 0, 'shp_cen_bolt12') super().make_parent(name) chmf_reinf_r = min(base_motor_d - base_d, base_h) self.shp = fcfun.shp_filletchamfer_dirpt(self.shp, self.axis_w, fc_pt=self.get_pos_dwh( 2, 0, 3), fillet=0, radius=(chmf_reinf_r - TOL)) if opt_sides == 0: for pt_w in (-3, 3): for pt_h in (0, 13): self.shp = fcfun.shp_filletchamfer_dirpt( self.shp, self.axis_d, fc_pt=self.get_pos_dwh(0, pt_w, pt_h), fillet=1, radius=chmf_r) self.shp = fcfun.shp_filletchamfer_dirpt( self.shp, self.axis_d, fc_pt=self.get_pos_dwh(5, pt_w, 1), fillet=1, radius=chmf_r) else: for pt_w in (-5, 5): for pt_h in (0, 1): self.shp = fcfun.shp_filletchamfer_dirpt( self.shp, self.axis_d, fc_pt=self.get_pos_dwh(0, pt_w, pt_h), fillet=1, radius=chmf_r) for pt_w in (-3, 3): for pt_h in (1, 13): self.shp = fcfun.shp_filletchamfer_dirpt( self.shp, self.axis_d, fc_pt=self.get_pos_dwh(0, pt_w, pt_h), fillet=1, radius=chmf_r) fuse = [] fuse.append(self.shp) shp_box_ref = fcfun.shp_box_dir(box_w=2 * self.bolthead_r, box_d=2 * self.bolthead_r, box_h=2 * self.bolthead_r, fc_axis_w=self.axis_w, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=0, ch=0, pos=self.get_pos_dwh(1, 0, 1)) shp_box_ref = fcfun.shp_filletchamfer_dirpt( shp_box_ref, self.axis_w, fc_pt=self.get_pos_dwh(5, 0, 2), fillet=0, radius=2 * self.bolthead_r - TOL) fuse.append(shp_box_ref) shp_final = fcfun.fuseshplist(fuse) self.shp = shp_final # Then the Part super().create_fco(name) self.fco.Placement.Base = FreeCAD.Vector(0, 0, 0) self.fco.Placement.Base = self.position
def __init__( self, filter_l=60., filter_w=25., filter_t=2.5, base_h=6., hold_d=10., filt_supp_in=2., filt_rim=3., filt_cen_d=0, fillet_r=1., # linear guides SEBLV16 y SEBS15, y MGN12H: boltcol1_dist=20 / 2., boltcol2_dist=12.5, #thorlabs breadboard distance boltcol3_dist=25, boltrow1_h=0, boltrow1_2_dist=12.5, # linear guide MGN12H boltrow1_3_dist=20., # linear guide SEBLV16 and SEBS15 boltrow1_4_dist=25., bolt_cen_mtr=4, bolt_linguide_mtr=3, # linear guide bolts beltclamp_t=3., #2.8, beltclamp_l=12., beltclamp_h=8., clamp_post_dist=4., sm_beltpost_r=1., tol=kcomp.TOL, axis_d=VX, axis_w=VY, axis_h=VZ, pos_d=0, pos_w=0, pos_h=0, pos=V0): shp_clss.Obj3D.__init__(self, axis_d, axis_w, axis_h) # save the arguments as attributes: frame = inspect.currentframe() args, _, _, values = inspect.getargvalues(frame) for i in args: if not hasattr(self, i): setattr(self, i, values[i]) # normal axes to print without support self.prnt_ax = self.axis_h # calculation of the dimensions: # hole for the filter, including tolerances: # Note that now the dimensions width and length are changed. # to depth and width # they are relative to the holder, not to the filter # no need to have the tolerances here: self.filt_hole_d = filter_w # + tol # depth self.filt_hole_w = filter_l # + tol # width in holder axis self.filt_hole_h = filter_t # + tol/2. # 0.5 tolerance for height # The hole under the filter to let the light go through # and big enough to hold the filter # we could take filter_hole dimensions or filter dimensiones # just the tolerance difference self.filt_supp_d = self.filt_hole_d - 2 * filt_supp_in self.filt_supp_w = self.filt_hole_w - 2 * filt_supp_in # look for the largest bolt head in the first row: # dictionary of the center bolt and 2nd and 3rd column self.bolt_cen_dict = kcomp.D912[bolt_cen_mtr] self.bolt_cen_head_r_tol = self.bolt_cen_dict['head_r_tol'] self.bolt_cen_r_tol = self.bolt_cen_dict['shank_r_tol'] self.bolt_cen_head_l_tol = self.bolt_cen_dict['head_l_tol'] # dictionary of the 1st column bolts (for the linear guide) self.bolt_linguide_dict = kcomp.D912[bolt_linguide_mtr] self.bolt_linguide_head_r_tol = self.bolt_linguide_dict['head_r_tol'] self.bolt_linguide_r_tol = self.bolt_linguide_dict['shank_r_tol'] self.bolt_linguide_head_l_tol = self.bolt_linguide_dict['head_l_tol'] max_row1_head_r_tol = max(self.bolt_linguide_head_r_tol, self.bolt_cen_head_r_tol) if boltrow1_h == 0: self.boltrow1_h = 2 * max_row1_head_r_tol elif boltrow1_h < 2 * max_row1_head_r_tol: self.boltrow1_h = 2 * max_row1_head_r_tol msg1 = 'boltrow1_h smaller than bolt head diameter' msg2 = 'boltrow1_h will be bolt head diameter' logger.warning(msg1 + msg2 + str(self.boltrow1_h)) # else # it will be as it is self.hold_h = (base_h + self.boltrow1_h + boltrow1_4_dist + 2 * self.bolt_linguide_head_r_tol) self.tot_h = self.hold_h + beltclamp_h self.beltclamp_blk_t = (hold_d - beltclamp_t) / 2. #self.clamp2cenpost = clamp_post_dist + s_beltclamp_r_sm # the large radius of the belt post self.lr_beltpost_r = (hold_d - 3) / 2. min_filt_cen_d = hold_d + filt_rim + filter_w / 2. if filt_cen_d == 0: filt_cen_d = hold_d + filt_rim + filter_w / 2. elif filt_cen_d < min_filt_cen_d: filt_cen_d = hold_d + filt_rim + filter_w / 2. msg = 'filt_cen_d is smaller than needed, taking: ' logger.warning(msg + str(filt_cen_d)) self.filt_cen_d = filt_cen_d self.tot_d = self.filt_cen_d + filter_w / 2. + filt_rim # find out if the max width if given by the filter or the holder base_w = filter_l + 2 * filt_rim hold_w = 2 * boltcol3_dist + 4 * self.bolt_cen_head_r_tol self.tot_w = max(base_w, hold_w) self.beltpost_l = (3 * self.lr_beltpost_r) + sm_beltpost_r self.clamp_lrbeltpostcen_dist = (self.beltpost_l - self.lr_beltpost_r + self.clamp_post_dist) self.d0_cen = 0 self.w0_cen = 1 # symmetrical self.h0_cen = 0 self.d_o[0] = V0 self.d_o[1] = self.vec_d(self.beltclamp_blk_t) self.d_o[2] = self.vec_d(hold_d / 2.) self.d_o[3] = self.vec_d(hold_d - self.beltclamp_blk_t) # at the beginning of the bolt head hole for the central bolt self.d_o[4] = self.vec_d(hold_d - self.bolt_cen_head_l_tol) self.d_o[5] = self.vec_d(hold_d - self.bolt_linguide_head_l_tol) self.d_o[6] = self.vec_d(hold_d) # at the beginning of the hole of the porta (no tolerance): self.d_o[7] = self.vec_d(self.filt_cen_d - filter_w / 2.) # inner side of porta thruhole self.d_o[8] = self.d_o[7] + self.vec_d(filt_supp_in) # at the center of the porta: self.d_o[9] = self.vec_d(self.filt_cen_d) # outer side of porta thruhole self.d_o[10] = self.vec_d(self.filt_cen_d + filter_w / 2. - filt_supp_in) # at the end of the hole of the porta (no tolerance): self.d_o[11] = self.vec_d(self.filt_cen_d + filter_w / 2.) self.d_o[12] = self.vec_d(self.tot_d) # these are negative because actually the pos_w indicates a negative # position along axis_w self.w_o[0] = V0 #1: at the first bolt column self.w_o[1] = self.vec_w(-boltcol1_dist) #2: at the second bolt column self.w_o[2] = self.vec_w(-boltcol2_dist) #3: at the third bolt column self.w_o[3] = self.vec_w(-boltcol3_dist) #7: at the end of the piece self.w_o[7] = self.vec_w(-self.tot_w / 2.) #6: at the inner side of the clamp rails # add belt_clamp because w_o are negative self.w_o[6] = self.w_o[7] + self.vec_w(beltclamp_l) #5: at the outer side of the clamp post (smaller circle) self.w_o[5] = self.w_o[6] + self.vec_w(clamp_post_dist) #4: at the inner side of the clamp post (larger circle) self.w_o[4] = self.w_o[5] + self.vec_w(self.beltpost_l) #0: at the bottom (base) self.h_o[0] = V0 #1: at the base for the porta self.h_o[1] = self.vec_h(base_h - self.filt_hole_h) #2: at the top of the base self.h_o[2] = self.vec_h(base_h) #3: first row of bolts self.h_o[3] = self.vec_h(base_h + self.boltrow1_h) #4: second row of bolts self.h_o[4] = self.h_o[3] + self.vec_h(boltrow1_2_dist) #5: third row of bolts, taking self.h_o[3] self.h_o[5] = self.h_o[3] + self.vec_h(boltrow1_3_dist) #6: 4th row of bolts self.h_o[6] = self.h_o[3] + self.vec_h(boltrow1_4_dist) #7: at the base of the belt clamp self.h_o[7] = self.vec_h(self.hold_h) #8: at the middle of the belt clamp self.h_o[8] = self.vec_h(self.hold_h + self.beltclamp_h / 2.) #9: at the top of the piece self.h_o[9] = self.vec_h(self.tot_h) # calculates the position of the origin, and keeps it in attribute pos_o self.set_pos_o() # -------- building of the piece # the base shp_base = fcfun.shp_box_dir(box_w=self.tot_w, box_d=self.tot_d, box_h=base_h, fc_axis_w=self.axis_w, fc_axis_d=self.axis_d, fc_axis_h=self.axis_h, cw=1, cd=0, ch=0, pos=self.pos_o) shp_base = fcfun.shp_filletchamfer_dir(shp_base, self.axis_h, fillet=1, radius=fillet_r) shp_base = shp_base.removeSplitter() # the holder to attach to a linear guide shp_holder = fcfun.shp_boxdir_fillchmfplane( box_w=self.tot_w, box_d=hold_d, box_h=self.hold_h, axis_d=self.axis_d, axis_h=self.axis_h, cw=1, cd=0, ch=0, fillet=1, radius=fillet_r, plane_fill=self.axis_d.negative(), both_planes=0, edge_dir=self.axis_h, pos=self.pos_o) #shp_holder = fcfun.shp_box_dir (box_w = self.tot_w, #box_d = hold_d, #box_h = self.hold_h, #fc_axis_w = self.axis_w, #fc_axis_d = self.axis_d, #fc_axis_h = self.axis_h, #cw = 1, cd = 0, ch = 1, #pos = self.pos_o) #shp_base = fcfun.shp_filletchamfer_dir (shp_base, self.axis_h, #fillet = 1, radius = fillet_r) shp_base = shp_base.removeSplitter() shp_l = shp_base.fuse(shp_holder) shp_l = shp_l.removeSplitter() # pos (6,0,2): position at the corner of the L shp_l = fcfun.shp_filletchamfer_dirpt(shp_l, fc_axis=self.axis_w, fc_pt=self.get_pos_dwh(6, 0, 2), fillet=0, radius=fillet_r) shp_l = shp_l.removeSplitter() # now we have the L shape with its chamfers and fillets # ------------------- Holes for the filter # include tolerances, along nh: only half of it, along h= 1 to make # the cut # pos (9,0,1) position at the center of the porta, at its bottom shp_filter_hole = fcfun.shp_box_dir_xtr(box_w=self.filt_hole_w, box_d=self.filt_hole_d, box_h=self.filt_hole_h, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=1, ch=0, xtr_h=1, xtr_nh=tol / 2., xtr_d=tol, xtr_nd=tol, xtr_w=tol, xtr_nw=tol, pos=self.get_pos_dwh(9, 0, 1)) # pos (9,0,0) position at the center of the porta, at the bottom of the # piece # no extra on top because it will be fused with shp_filter_hole shp_filter_thruhole = fcfun.shp_box_dir_xtr(box_w=self.filt_supp_w, box_d=self.filt_supp_d, box_h=base_h, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, cw=1, cd=1, ch=0, xtr_h=0, xtr_nh=1, xtr_d=tol, xtr_nd=tol, xtr_w=tol, xtr_nw=tol, pos=self.get_pos_dwh( 9, 0, 0)) shp_fuse_filter_hole = shp_filter_hole.fuse(shp_filter_thruhole) shp_l = shp_l.cut(shp_fuse_filter_hole) shp_l = shp_l.removeSplitter() # the L with the hole in the base is done # ---------------- Holes for the bolts bolt_list = [] shp_cen_bolt = fcfun.shp_bolt_dir( r_shank=self.bolt_cen_r_tol, l_bolt=hold_d, r_head=self.bolt_cen_head_r_tol, l_head=self.bolt_cen_head_l_tol, xtr_head=1, xtr_shank=1, support=0, #not at printing directi fc_normal=self.axis_d.negative(), pos_n=2, pos=self.get_pos_dwh(0, 0, 3)) bolt_list.append(shp_cen_bolt) # the rest of the bolts come in pairs: for w_side in [-1, 1]: # the wider bolts (although can be smaller) for cen_col, cen_row in zip([2, 3], [4, 3]): boltpos = self.get_pos_dwh(0, w_side * cen_col, cen_row) shp_cen_bolt = fcfun.shp_bolt_dir( r_shank=self.bolt_cen_r_tol, l_bolt=hold_d, r_head=self.bolt_cen_head_r_tol, l_head=self.bolt_cen_head_l_tol, xtr_head=1, xtr_shank=1, support=0, #not at printing directi fc_normal=self.axis_d.negative(), pos_n=2, pos=boltpos) bolt_list.append(shp_cen_bolt) # the smaller bolts (although can be larger). Linear guide # first row: boltpos = self.get_pos_dwh(0, w_side * 1, 3) shp_lin_bolt = fcfun.shp_bolt_dir( r_shank=self.bolt_linguide_r_tol, l_bolt=hold_d, r_head=self.bolt_linguide_head_r_tol, l_head=self.bolt_linguide_head_l_tol, xtr_head=1, xtr_shank=1, support=0, #not at printing directi fc_normal=self.axis_d.negative(), pos_n=2, pos=boltpos) bolt_list.append(shp_lin_bolt) # 3rd and 4th row. Just 2 shanks and a stadium per side for linrow in [5, 6]: boltpos = self.get_pos_dwh(0, w_side * 1, linrow) shp_lin_shank = fcfun.shp_cylcenxtr( r=self.bolt_linguide_r_tol, h=hold_d, normal=self.axis_d, ch=0, xtr_top=0, #no need: stadium xtr_bot=1, pos=boltpos) bolt_list.append(shp_lin_shank) # the stadium for both bolts head (they are too close) stadpos = self.get_pos_dwh(6, w_side * 1, 5) shp_stad = fcfun.shp_stadium_dir( length=boltrow1_4_dist - boltrow1_3_dist, radius=self.bolt_linguide_head_r_tol, height=self.bolt_linguide_head_l_tol, fc_axis_h=self.axis_d.negative(), fc_axis_l=self.axis_h, ref_l=2, ref_h=2, xtr_h=0, xtr_nh=1, pos=stadpos) bolt_list.append(shp_stad) shp_bolts = fcfun.fuseshplist(bolt_list) shp_l = shp_l.cut(shp_bolts) # ---------------- Belt clamps # at both sides clamp_list = [] for w_side in [-1, 1]: clamp_pos = self.get_pos_dwh(0, w_side * 7, 7) if w_side == 1: clamp_axis_w = self.axis_w.negative() else: clamp_axis_w = self.axis_w shp_clamp = fcfun.shp_box_dir_xtr(box_w=beltclamp_l, box_d=self.beltclamp_blk_t, box_h=beltclamp_h, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d, fc_axis_w=clamp_axis_w, cw=0, cd=0, ch=0, xtr_nh=1, pos=clamp_pos) # fillet the corner shp_clamp = fcfun.shp_filletchamfer_dirpt(shp_clamp, self.axis_h, fc_pt=clamp_pos, fillet=1, radius=fillet_r) shp_clamp = shp_clamp.removeSplitter() clamp_list.append(shp_clamp) # the other clamp, with no fillet clamp_pos = self.get_pos_dwh(6, w_side * 7, 7) shp_clamp = fcfun.shp_box_dir_xtr(box_w=beltclamp_l, box_d=self.beltclamp_blk_t, box_h=beltclamp_h, fc_axis_h=self.axis_h, fc_axis_d=self.axis_d.negative(), fc_axis_w=clamp_axis_w, cw=0, cd=0, ch=0, xtr_nh=1, pos=clamp_pos) clamp_list.append(shp_clamp) # the belt post beltpost_pos = self.get_pos_dwh(2, w_side * 5, 7) shp_beltpost = fcfun.shp_belt_dir(center_sep=2 * self.lr_beltpost_r, rad1=sm_beltpost_r, rad2=self.lr_beltpost_r, height=beltclamp_h, fc_axis_h=self.axis_h, fc_axis_l=clamp_axis_w, ref_l=3, ref_h=2, xtr_h=0, xtr_nh=1, pos=beltpost_pos) clamp_list.append(shp_beltpost) shp_filterholder = shp_l.multiFuse(clamp_list) shp_filterholder = shp_filterholder.removeSplitter() #Part.show (shp_filterholder) self.shp = shp_filterholder
def __init__(self, d_endstop, rail_l = 15, base_h = 5., h = 0, holder_out = 2., #csunk = 1, mbolt_d = 3., endstop_nut_dist = 0, min_d = 0, axis_d = VX, axis_w = V0, axis_h = VZ, pos_d = 1, pos_w = 1, pos_h = 1, pos = V0, wfco = 1, name = 'simple_enstop_holder'): self.pos = FreeCAD.Vector(0,0,0) self.position = pos self.wfco = wfco self.name = name self.base_h = base_h, # normalize the axis axis_h = DraftVecUtils.scaleTo(axis_h,1) axis_d = DraftVecUtils.scaleTo(axis_d,1) if axis_w == V0: axis_w = axis_h.cross(axis_d) else: axis_w = DraftVecUtils.scaleTo(axis_w,1) axis_h_n = axis_h.negative() axis_d_n = axis_d.negative() axis_w_n = axis_w.negative() self.axis_h = axis_h self.axis_d = axis_d self.axis_w = axis_w self.d0_cen = 0 self.w0_cen = 1 # centered self.h0_cen = 0 self.pos_d = pos_d self.pos_w = pos_w self.pos_h = pos_h self.pos = pos Obj3D.__init__(self, axis_d, axis_w, axis_h, name) # best axis to print, to be pointing up: self.axis_print = axis_h self.d_endstop = d_endstop # :holder_out # __:________:____________: :.................. # | _________ | | : # | (_________) ----| 0 | + tot_w # | _________ ----| |-----> axis_d : # | (_________) ----| 0 | : # |__________________|_____|...................: # : : : : : : : # : :..rail_l.: : : : : # : : : : :.: : # :bolthead_d : : : +estp_bolt_dist # : : : : # bolthead_r: :.......: # : +estp_d # : : # :.estp_tot_d: # :...................._..: : # tot_d # The width depend which side is larger # # ...... ______________________ .... # mbolt_head_r ......| ________ | | : # mbolt_head_d ......| (________) ---| 0 | : #mbolt_head_d or more ......| ________ ---| | + estp_w or more # mbolt_head_d ......| (________) ---| 0 | : # mbolt_head_r ......|________________|_____|....: # it can have a second hole: # : :estop_topbolt_dist # : holder_out # __:________:______________: :.................. # | _________ | | : # | (_________) ----| 0 0 | + tot_w # | _________ ----| |-----> axis_d : # | (_________) ----| 0 0 | : # |__________________|_______|...................: # : : # mounting bolt data d_mbolt = kcomp.D912[int(mbolt_d)] #dictionary of the mounting bolt #print(str(d_mbolt)) mbolt_r_tol = d_mbolt['shank_r_tol'] mbolt_head_r = d_mbolt['head_r'] mbolt_head_r_tol = d_mbolt['head_r_tol'] mbolt_head_l = d_mbolt['head_l'] print (str(mbolt_head_l)) # endstop data. change h->d, d->h, l->w estp_tot_d = d_endstop['HT'] estp_d = d_endstop['H'] estp_bolt_dist = d_endstop['BOLT_H'] estp_bolt_sep = d_endstop['BOLT_SEP'] estp_bolt_d = d_endstop['BOLT_D'] #diameter, not depth estp_w = d_endstop['L'] # if there is a second bolt if 'BOLT_TOP_H' in d_endstop: estop_2ndbolt_topdist = d_endstop['BOLT_TOP_H'] else: estop_2ndbolt_topdist = 0 # length of the pins: estp_pin_d = estp_tot_d - estp_d if min_d == 0: tot_d = 3*mbolt_head_r + rail_l + estp_tot_d - holder_out # nut axis: (nut axis of the hexagon vertex hex_verx = axis_d else: # Taking the minimum lenght, very tight tot_d = (3*mbolt_head_r + rail_l + estp_d - holder_out + estp_pin_d/2.) hex_verx = axis_w # less space # Total width is the largest value from: # - the width(length) of the endstop # - the rail width: 2 bolt head diameters, and 2 more: 1 diameter # between, and a radius to the end tot_w = max(estp_w, 8 * mbolt_head_r) if h== 0: tot_h = base_h + mbolt_head_l else: tot_h = base_h + mbolt_head_l if tot_h > h: logger.debug('h is smaller that it should, taking: ') logger.debug(str(tot_h)) else: tot_h = h self.tot_h = tot_h self.tot_w = tot_w self.tot_d = tot_d if endstop_nut_dist == 0: endstop_nut_l = kcomp.NUT_D934_L[estp_bolt_d]+TOL else: if endstop_nut_dist > tot_h - kcomp.NUT_D934_L[estp_bolt_d]+TOL: logger.debug('endstop_nut_dist: ' + str(endstop_nut_dist) + ' larger than total height - (nut length+tol): ' + str(tot_h) + ' - ' + str( kcomp.NUT_D934_L[estp_bolt_d] + TOL)) endstop_nut_l = kcomp.NUT_D934_L[estp_bolt_d]+TOL else: endstop_nut_l = tot_h - endstop_nut_dist # ------------ DISTANCES ON AXIS_D # ref_d points: fc_axis_h # 1___2______3_______4__.5............. ref_h = 2 # | :..........: : : |:..... + h # |__:________:_____:_:_|:.....base_h.: ref_h = 1 # the end it is not on the holder because of -holder_out # distance from 1 to 2 in axis_d # vectors from the origin to the points along axis_d: self.d_o[0] = V0 self.d_o[1] = self.vec_d(2* mbolt_head_r) self.d_o[2] = self.vec_d(2* mbolt_head_r + rail_l) self.d_o[3] = self.vec_d((tot_d + holder_out) - (estp_d - estp_bolt_dist)) self.d_o[4] = self.vec_d(tot_d + holder_out) if estop_2ndbolt_topdist > 0 : self.d_o[5] = self.vec_d(tot_d + holder_out - estop_2ndbolt_topdist) else: self.d_o[5] = self.d_o[3] # vectors from the origin to the points along axis_w: self.w_o[0] = V0 self.w_o[1] = self.vec_w(estp_bolt_sep/2.) self.w_o[2] = self.vec_w(tot_w/2. - 2* mbolt_head_r) self.w_o[3] = self.vec_w(tot_w/2.) # vectors from the origin to the points along axis_h: self.h_o[0] = V0 self.h_o[1] = self.vec_h(tot_h) # calculates the position of the origin, and keeps it in attribute pos_o self.set_pos_o() # TODO: clear this parts when points d_o, w_o, h_o dis_1_2_d = 2* mbolt_head_r # d_o[1] dis_1_3_d = dis_1_2_d + rail_l # d_o[2] #dis_2_3_d = rail_l dis_1_5_d = tot_d + holder_out # d_o[4] dis_1_4_d = dis_1_5_d - (estp_d - estp_bolt_dist) # d_o[3] # distances to the new point, that is the second bolt hole, if exists if estop_2ndbolt_topdist > 0 : dis_1_6_d = dis_1_5_d - estop_2ndbolt_topdist else: # same as 4: (to avoid errors) it will be the same hole dis_1_6_d = dis_1_4_d fc_1_2_d = self.d_o[1] fc_1_3_d = self.d_o[2] fc_1_4_d = self.d_o[3] fc_1_5_d = self.d_o[4] fc_1_6_d = self.d_o[5] # vector from the reference point to point 1 on axis_d if pos_d == 0: refto_1_d = V0 elif pos_d == 1: refto_1_d = fc_1_2_d.negative() elif pos_d == 2: refto_1_d = fc_1_3_d.negative() elif pos_d == 3: refto_1_d = fc_1_4_d.negative() elif pos_d == 4: refto_1_d = fc_1_5_d.negative() elif pos_d == 5: refto_1_d = fc_1_6_d.negative() else: logger.error('wrong reference point') # ------------ DISTANCES ON AXIS_W # ref_w points # fc_axis_w # _____________________ : # | ________ | |: # | (________) ---| 0 |: # 1 ________ ---| |:-----> fc_axis_d. # 3 (________) ---| 2 |: # 4________________|____|: # distance from 1 to 2 on axis_w dis_1_2_w = estp_bolt_sep/2. dis_1_4_w = tot_w/2. dis_1_3_w = dis_1_4_w - 2* mbolt_head_r fc_1_2_w = self.w_o[1] fc_1_3_w = self.w_o[2] fc_1_4_w = self.w_o[3] # vector from the reference point to point 1 on axis_w if pos_w == 0: refto_1_w = V0 elif pos_w == 1: refto_1_w = fc_1_2_w.negative() elif pos_w == 2: refto_1_w = fc_1_3_w.negative() elif pos_w == 3: refto_1_w = fc_1_4_w.negative() else: logger.error('wrong reference point') # ------------ DISTANCES ON AXIS_H fc_1_2_h = DraftVecUtils.scale(axis_h, tot_h) fc_2_1_h = fc_1_2_h.negative() if pos_h == 0: refto_2_h = self.h_o[1] elif pos_h == 1: refto_2_h = V0 else: logger.error('wrong reference point') # Situation of the point on d=1, s=1, h=2 # ____________ # / # * d1_w1_h2 # /____________ # | # # this is an absolute position # super().get_pos_dwh(pos_d,pos_w,pos_h) d1_w1_h2_pos = self.pos + refto_1_d + refto_1_w + refto_2_h d1_w1_h1_pos = d1_w1_h2_pos + fc_2_1_h # draw the box from this point d1 s1 h2 shp_box = fcfun.shp_box_dir(box_w = tot_w, box_d = tot_d, box_h = tot_h, fc_axis_h = axis_h_n, fc_axis_d = axis_d, cw = 1, cd = 0, ch = 0, pos = d1_w1_h2_pos) shp_box = fcfun.shp_filletchamfer_dir(shp_box, fc_axis = axis_h, fillet=1, radius = 2) holes = [] # holes for the endstop bolts, point: d4 w2 h1 for fc_1_2_wi in [fc_1_2_w, fc_1_2_w.negative()]: pos_estpbolt = d1_w1_h1_pos + fc_1_4_d + fc_1_2_wi # hole with the nut hole shp_estpbolt = fcfun.shp_bolt_dir ( r_shank= (estp_bolt_d+TOL)/2., l_bolt = tot_h, # 1 TOL didnt fit r_head = (kcomp.NUT_D934_D[estp_bolt_d]+2*TOL)/2., l_head = endstop_nut_l, hex_head = 1, xtr_head = 1, xtr_shank = 1, fc_normal = axis_h, fc_verx1 = hex_verx, pos = pos_estpbolt) holes.append(shp_estpbolt) # it can have a second hole if estop_2ndbolt_topdist >0: pos_estp_top_bolt = d1_w1_h1_pos + fc_1_6_d + fc_1_2_wi # hole with the nut hole shp_estpbolt = fcfun.shp_bolt_dir ( r_shank= (estp_bolt_d+TOL)/2., l_bolt = tot_h, # 1 TOL didnt fit r_head = (kcomp.NUT_D934_D[estp_bolt_d]+2*TOL)/2., l_head = endstop_nut_l, hex_head = 1, xtr_head = 1, xtr_shank = 1, fc_normal = axis_h, fc_verx1 = hex_verx, pos = pos_estp_top_bolt) holes.append(shp_estpbolt) # holes for the rails, point d2 w3 h2 for fc_1_3_wi in [fc_1_3_w, fc_1_3_w.negative()]: #hole for the rails, use the function stadium rail_pos = d1_w1_h2_pos + fc_1_2_d + fc_1_3_wi shp_rail_sunk = fcfun.shp_stadium_dir ( length = rail_l, radius = mbolt_head_r_tol, height = mbolt_head_l, fc_axis_l = axis_d, fc_axis_h = axis_h_n, ref_l = 2, #at the center of semicircle ref_s = 1, # symmetrical on the short side ref_h = 2, xtr_h = 0, xtr_nh = 1, pos = rail_pos) shp_rail = fcfun.shp_stadium_dir ( length = rail_l, radius = mbolt_r_tol, height = tot_h, fc_axis_l = axis_d, fc_axis_h = axis_h_n, ref_l = 2, ref_s = 1, ref_h = 2, xtr_h = 1, xtr_nh = 0, pos = rail_pos) holes.append(shp_rail) holes.append(shp_rail_sunk) shp_holes = fcfun.fuseshplist(holes) shp_holder = shp_box.cut(shp_holes) self.shp = shp_holder if wfco == 1: super().create_fco() # Need to set first in (0,0,0) and after that set the real placement. # This enable to do rotations without any issue self.fco.Placement.Base = FreeCAD.Vector(0,0,0) self.fco.Placement.Base = self.position