コード例 #1
0
    def __init__(
            self,
            pitch=2.,
            n_teeth=20,
            toothed_h=7.5,
            top_flange_h=1.,
            bot_flange_h=0,
            tot_h=16.,
            flange_d=15.,
            base_d=15.,
            shaft_d=5.,
            tol=0,
            axis_d=VX,
            axis_w=VY,
            axis_h=VZ,
            pos_d=0,
            pos_w=0,
            pos_h=0,
            pos=V0,
            model_type=1,  # dimensional model
            name=None):

        if name == None:
            name = 'gt' + str(int(pitch)) + '_pulley_' + str(n_teeth)
        self.name = name

        if (((axis_d is None) or (axis_d == V0))
                and ((axis_w is None) or (axis_w == V0))):
            # both are null, we create a random perpendicular vectors
            axis_d = fcfun.get_fc_perpend1(axis_h)
            axis_w = axis_h.cross(axis_d)
        else:
            if ((axis_d is None) or (axis_d == V0)):
                axis_d = axis_w.cross(axis_h)
            elif ((axis_w is None) or (axis_w == V0)):
                axis_w = axis_h.cross(axis_d)
            # all axis are defined

        Obj3D.__init__(self, axis_d, axis_w, axis_h, name)

        if (top_flange_h > 0 or bot_flange_h > 0) and flange_d == 0:
            logger.debug("Flange height is not null, but diameter is null")
            logger.debug("Flange diameter will be the same as the base")
            flange_d = base_d
            self.flange_d = flange_flange_d

        # 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])

        # belt dictionary:
        self.belt_dict = kcomp.GT[pitch]
        # diameters of the pulley:
        # pitch diameter, it is not on the pulley, but outside, on the belt
        self.pitch_d = n_teeth * pitch / math.pi
        self.pitch_r = self.pitch_d / 2.
        # out radius and diameter, diameter at the outer part of the teeth
        self.tooth_out_r = self.pitch_r - self.belt_dict['PLD']
        self.tooth_out_d = 2 * self.tooth_out_r
        # inner radius and diameter, diameter at the inner part of the teeth
        self.tooth_in_r = self.tooth_out_r - self.belt_dict['TOOTH_H']
        self.tooth_in_d = 2 * self.tooth_in_r

        self.base_r = base_d / 2.
        self.shaft_r = shaft_d / 2.
        self.flange_r = flange_d / 2.

        self.base_d = base_d
        # height of the base, without the toothed part and the flange
        self.base_h = tot_h - toothed_h - top_flange_h - bot_flange_h
        self.tot_h = tot_h
        self.toothed_h = toothed_h
        self.top_flange_h = top_flange_h
        self.bot_flange_h = bot_flange_h

        self.h0_cen = 0
        self.d0_cen = 1  # symmetrical
        self.w0_cen = 1  # symmetrical

        # vectors from the origin to the points along axis_h:
        self.h_o[0] = V0
        self.h_o[1] = self.vec_h(self.base_h)
        self.h_o[2] = self.vec_h(self.base_h + self.bot_flange_h)
        self.h_o[3] = self.vec_h(self.base_h + self.bot_flange_h +
                                 toothed_h / 2.)
        self.h_o[4] = self.vec_h(self.tot_h - top_flange_h)
        self.h_o[5] = self.vec_h(self.tot_h)

        # vectors from the origin to the points along axis_d:
        # these are negative because actually the pos_d indicates a negative
        # position along axis_d (this happens when it is symmetrical)
        self.d_o[0] = V0
        self.d_o[1] = self.vec_d(-self.shaft_r)
        self.d_o[2] = self.vec_d(-self.tooth_in_r)
        self.d_o[3] = self.vec_d(-self.tooth_out_r)
        self.d_o[4] = self.vec_d(-self.pitch_r)
        self.d_o[5] = self.vec_d(-self.base_r)
        self.d_o[6] = self.vec_d(-self.flange_r)

        # position along axis_w
        self.w_o[0] = V0
        self.w_o[1] = self.vec_w(-self.shaft_r)
        self.w_o[2] = self.vec_w(-self.tooth_in_r)
        self.w_o[3] = self.vec_w(-self.tooth_out_r)
        self.w_o[4] = self.vec_w(-self.pitch_r)
        self.w_o[5] = self.vec_w(-self.base_r)
        self.w_o[6] = self.vec_w(-self.flange_r)

        # calculates the position of the origin, and keeps it in attribute pos_o
        self.set_pos_o()

        shp_fuse_list = []
        # Cilynder with a hole, with an extra for the fusion
        # calculation of the extra at the bottom to make the fusion
        if self.bot_flange_h > 0:
            xtr_bot = self.bot_flange_h / 2.
        elif self.base_d > self.tooth_out_d:
            xtr_bot = self.base_h / 2.
        else:
            xtr_bot = 0
        # external diameter (maybe later teeth will be made
        shp_tooth_cyl = fcfun.shp_cylhole_gen(
            r_out=self.tooth_out_r,
            r_in=self.shaft_r + tol,
            h=self.toothed_h,
            axis_h=self.axis_h,
            pos_h=1,  #position at the bottom
            xtr_top=top_flange_h / 2.,
            xtr_bot=xtr_bot,
            pos=self.get_pos_h(2))
        shp_fuse_list.append(shp_tooth_cyl)
        if self.bot_flange_h > 0:
            # same width
            if self.flange_d == self.base_d:
                shp_base_flg_cyl = fcfun.shp_cylholedir(
                    r_out=self.base_r,
                    r_in=self.shaft_r + tol,
                    h=self.base_h + self.bot_flange_h,
                    normal=self.axis_h,
                    pos=self.pos_o)
                shp_fuse_list.append(shp_base_flg_cyl)
            else:
                shp_base_cyl = fcfun.shp_cylholedir(r_out=self.base_r,
                                                    r_in=self.shaft_r + tol,
                                                    h=self.base_h,
                                                    normal=self.axis_h,
                                                    pos=self.pos_o)
                shp_bot_flange_cyl = fcfun.shp_cylholedir(
                    r_out=self.flange_r,
                    r_in=self.shaft_r + tol,
                    h=self.bot_flange_h,
                    normal=self.axis_h,
                    pos=self.get_pos_h(1))
                shp_fuse_list.append(shp_base_cyl)
                shp_fuse_list.append(shp_bot_flange_cyl)
        else:  #no bottom flange
            shp_base_cyl = fcfun.shp_cylholedir(r_out=self.base_r,
                                                r_in=self.shaft_r + tol,
                                                h=self.base_h,
                                                normal=self.axis_h,
                                                pos=self.pos_o)
            shp_fuse_list.append(shp_base_cyl)
        if self.top_flange_h > 0:
            shp_top_flange_cyl = fcfun.shp_cylholedir(r_out=self.flange_r,
                                                      r_in=self.shaft_r + tol,
                                                      h=self.top_flange_h,
                                                      normal=self.axis_h,
                                                      pos=self.get_pos_h(4))
            shp_fuse_list.append(shp_top_flange_cyl)

        shp_pulley = fcfun.fuseshplist(shp_fuse_list)

        shp_pulley = shp_pulley.removeSplitter()

        self.shp = shp_pulley

        # normal axes to print without support
        self.prnt_ax = self.axis_h

        super().create_fco()

        # 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])
コード例 #2
0
    def __init__ (self, depth,
                  aluprof_dict,
                  xtr_d=0, xtr_nd=0,
                  axis_d = VX, axis_w = VY, axis_h = V0,
                  pos_d = 0, pos_w = 0, pos_h = 0,
                  pos = V0,
                  model_type = 1, # dimensional model
                  name = None):
        
        width = aluprof_dict['w']
        depth = depth
        thick = aluprof_dict['t']
        slot = aluprof_dict['slot']
        insquare = aluprof_dict['insq']
        indiam = aluprof_dict['indiam']


        # either axis_w or axis_h can be V0, but not both
        if (axis_w is None) or (axis_w == V0):
            if (axis_h is None) or (axis_h == V0):
                logger.error('Either axis_w or axis_h must be defined')
                logger.warning('getting a random perpendicular verctor')
                axis_w = fcfun.get_fc_perpend1(axis_d)
            else:
                axis_w = axis_h.cross(axis_d)

        if (axis_h is None) or (axis_h == V0):
            axis_h = axis_d.cross(axis_w)

        if name == None:
            name = ( 'aluprof_w' + str(int(aluprof_dict['w']))
                        + 'l_' + str(int(xtr_nd + depth + xtr_d)))

        Obj3D.__init__(self, axis_d, axis_w, axis_h, name = 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

        self.d0_cen = 0
        self.w0_cen = 1 # symmetric
        self.h0_cen = 1 # symmetric

        # total length (depth)
        self.tot_d = xtr_nd + depth + xtr_d

        # vectors from the origin to the points along axis_d:
        self.d_o[0] = V0 # origin
        self.d_o[1] = self.vec_d(xtr_nd) #if xtr_nd= 0: same as d_o[0]
        # middle point, not considering xtr_nd and xtr_d
        self.d_o[2] = self.vec_d(xtr_nd + depth/2.)
        # middle point considering xtr_nd and xtr_d
        self.d_o[3] = self.vec_d(self.tot_d /2.)
        self.d_o[4] = self.vec_d(xtr_nd + depth)
        self.d_o[5] = self.vec_d(self.tot_d)

        # vectors from the origin to the points along axis_w:
        # symmetric: negative
        self.w_o[0] = V0 # center: origin
        self.w_o[1] = self.vec_w(-insquare/2.)
        self.w_o[2] = self.vec_w(-(width/2. - thick))
        self.w_o[3] = self.vec_w(-width/2.)

        # vectors from the origin to the points along axis_h:
        # symmetric: negative
        self.h_o[0] = V0 # center: origin
        self.h_o[1] = self.vec_h(-insquare/2.)
        self.h_o[2] = self.vec_h(-(width/2. - thick))
        self.h_o[3] = self.vec_h(-width/2.)

        # calculates the position of the origin, and keeps it in attribute pos_o
        self.set_pos_o()

        shp_alu_wire = fcfun.shp_aluwire_dir (width, thick, slot, insquare,
                                              fc_axis_x = self.axis_w,
                                              fc_axis_y = self.axis_h,
                                              ref_x = 1, # pos_o is centered
                                              ref_y = 1, # pos_o is centered
                                              pos = self.pos_o)


        # make a face of the wire
        shp_alu_face = Part.Face (shp_alu_wire)
        # inner hole
        if indiam > 0 :
            hole =  Part.makeCircle (indiam/2.,   # Radius
                                     self.pos_o,  # Position
                                     self.axis_d)  # direction
            wire_hole = Part.Wire(hole)
            face_hole = Part.Face(wire_hole)
            shp_alu_face = shp_alu_face.cut(face_hole)

        # extrude it
        dir_extrud = DraftVecUtils.scaleTo(self.axis_d, self.tot_d)
        shp_aluprof = shp_alu_face.extrude(dir_extrud)

        self.shp = shp_aluprof

        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