示例#1
0
 def compo_solid(self):
     extrusion_vector = self.plane.vectors[0].Cross(self.plane.vectors[1])
     return primitives3D.ExtrudedProfile(self.plane.origin,
                                         self.plane.vectors[0],
                                         self.plane.vectors[1],
                                         self.contour, [],
                                         extrusion_vector * self.height,
                                         color=(0.44313725, 0.27058824,
                                                0.12156863))
示例#2
0
    def babylon(self, xy_position, z_position):
        primitives = []

        ## AFFICHAGE EN CYLINDRE ##
        #        pos = vm.Point3D((xy_position[0], xy_position[1], z_position))
        #        axis = vm.Vector3D((0,0,1))
        #        radius = self.diameter/2
        #        length = self.length
        #        cylinder = p3d.Cylinder(pos, axis, radius, length)
        #        primitives.append(cylinder)

        ## AFFICHAGE EN ROUE DENTEE ##
        plane_origin = vm.Point3D(
            (xy_position[0], xy_position[1], z_position - self.length / 2))
        x = vm.x3D
        y = vm.y3D
        vector = vm.Vector3D((0, 0, self.length))

        if self.n_teeth is None:
            n_teeth = int(round(self.diameter * 100, 0))
        else:
            n_teeth = self.n_teeth
        angle = 2 * math.pi / n_teeth
        inner_diameter = 0.90 * self.diameter
        teeth_l = (2 * math.pi * self.diameter / 2) / (1.5 * n_teeth)
        pt1 = vm.Point2D(
            (-teeth_l / 2, (inner_diameter**2 / 4 - teeth_l**2 / 4)**0.5))
        pt5 = vm.Point2D(
            (teeth_l / 2, (inner_diameter**2 / 4 - teeth_l**2 / 4)**0.5))
        pt2 = vm.Point2D((pt1.vector[0] / 2, self.diameter / 2))
        pt4 = vm.Point2D((pt5.vector[0] / 2, self.diameter / 2))
        rls_points = [pt1, pt2, pt4, pt5]
        for i in range(n_teeth - 1):
            new_pt1 = rls_points[-4].Rotation(vm.o2D, -angle)
            new_pt2 = rls_points[-3].Rotation(vm.o2D, -angle)
            new_pt4 = rls_points[-2].Rotation(vm.o2D, -angle)
            new_pt5 = rls_points[-1].Rotation(vm.o2D, -angle)
            rls_points.extend([new_pt1, new_pt2, new_pt4, new_pt5])

        rls_points.reverse()
        rls = p2d.OpenedRoundedLineSegments2D(rls_points, {})
        outer_contour2d = vm.Contour2D([rls])
        extrusion = p3d.ExtrudedProfile(plane_origin, x, y, outer_contour2d,
                                        [], vector)
        primitives.append(extrusion)
        return primitives
示例#3
0
#p7=vm.Point2D((0,r4))
l2 = vm.Circle2D(pc, r4)

c1 = vm.Contour2D(L)
c2 = vm.Contour2D([l2])

po = vm.Point3D((0, 0, 0))
xp = vm.Vector3D((1, 0, 0))
yp = vm.Vector3D((0, 1, 0))

#c1.MPLPlot()
#extr_vect=vm.Vector3D((0,0,e))

profile_straight = primitives3D.ExtrudedProfile(po,
                                                xp,
                                                yp,
                                                c1, [c2], (0, 0, e),
                                                name='straight')
#
#model_straight=vm.VolumeModel([profile_straight])

profile_helical = primitives3D.HelicalExtrudedProfile(po,
                                                      xp,
                                                      yp,
                                                      vm.Vector3D((0, 0, 0)),
                                                      vm.Vector3D((0, 0, e)),
                                                      28 * 3.14 / 180,
                                                      c1, [c2],
                                                      name='helical')

model = vm.VolumeModel([('helical', [profile_helical]),
示例#4
0
#hole = volmdlr.Circle2D(p6, 0.01)
#inner_profile = primitives2D.RoundedLineSegments2D([p6, p7, p8], {0: 0.5}, closed = True)
l1 = volmdlr.LineSegment2D(p6, p7)
l2 = volmdlr.LineSegment2D(p7, p8)
l3 = volmdlr.LineSegment2D(p8, p6)
c2 = volmdlr.Contour2D([l1, l2, l3])

#c1 = volmdlr.Contour2D([outer_profile])
#c2 = volmdlr.Contour2D([inner_profile])

# f, a = outer_profile.MPLPlot()
# c2.MPLPlot(a)

profile = primitives3D.ExtrudedProfile(volmdlr.O3D,
                                       volmdlr.Y3D,
                                       volmdlr.Z3D,
                                       outer_profile, [c2],
                                       volmdlr.X3D * 0.1,
                                       name='extrusion')
dmin, p1, p2 = cyl1.minimum_distance(profile.faces[0], return_points=True)
face_min = profile.faces[0]
# print('dmin', dmin)
for face in profile.faces[1:]:
    dtest, ptest1, ptest2 = cyl1.minimum_distance(face, return_points=True)
    # print('dtest', dtest)
    if dtest < dmin:
        p1, p2 = ptest1, ptest2
        dmin = dtest
        face_min = face

# print('>>>>>>>>> distance minimale', dmin)
示例#5
0
    0: 0.01,
    1: 0.01,
    2: 0.015,
    3: 0.010,
    4: 0.012,
    5: 0.008
}, True)
outer_rl = inner_rl.Offset(-thickness)
inner_contour = vm.Contour2D([inner_rl])
outer_contour = vm.Contour2D([outer_rl])

f, a = inner_contour.MPLPlot()
outer_contour.MPLPlot(a)

sides = primitives3D.ExtrudedProfile(vm.o3D, vm.x3D, vm.y3D, outer_contour,
                                     [inner_contour],
                                     (height - 2 * thickness) * vm.z3D,
                                     'sides')
bottom = primitives3D.ExtrudedProfile(vm.o3D, vm.x3D, vm.y3D, outer_contour,
                                      [], -thickness * vm.z3D, 'bottom')

screw_holes_rl = inner_rl.Offset(-(thickness + screw_holes_clearance +
                                   0.5 * screw_holes_diameter))
screw_holes = []
l = screw_holes_rl.Length()
for i in range(n_screws):
    s = i * l / n_screws
    p = screw_holes_rl.PointAtCurvilinearAbscissa(s)
    screw_holes.append(
        vm.Contour2D([vm.Circle2D(p, screw_holes_diameter * 0.5)]))

belt_outer_rl = inner_rl.Offset(-(2 * screw_holes_clearance +
示例#6
0
c3 = vm.Contour2D([circle1])
c4 = vm.Contour2D([circle2])

e0 = vm.Point2D((0, 0.00))
e1 = vm.Point2D((0, 0.03))
e2 = vm.Point2D((0.11, 0.03))
e3 = vm.Point2D((0.11, 0.04))
e4 = vm.Point2D((0.13, 0.04))
e5 = vm.Point2D((0.13, 0))

points2 = [e0, e1, e2, e3, e4, e5]
c5 = primitives2D.ClosedRoundedLineSegments2D(points2, {})

profile = primitives3D.ExtrudedProfile(vm.O3D,
                                       vm.Y3D,
                                       vm.Z3D,
                                       c1, [],
                                       vm.X3D * 0.40,
                                       name='extrusion')
profile1 = primitives3D.ExtrudedProfile(vm.O3D,
                                        vm.Y3D,
                                        vm.Z3D,
                                        c2, [],
                                        -vm.X3D * 0.015,
                                        name='extrusion2')
profile2 = primitives3D.ExtrudedProfile(vm.O3D,
                                        vm.Y3D,
                                        vm.Z3D,
                                        c3, [],
                                        -vm.X3D * 0.015,
                                        name='extrusion3')
profile3 = primitives3D.ExtrudedProfile(vm.O3D,
示例#7
0
 def voldmlr_primitives(self):
     contour = self.contour()
     volumes = [
         p3d.ExtrudedProfile(vm.O3D, vm.X3D, vm.Z3D, contour, [], vm.Y3D)
     ]
     return volumes
示例#8
0
    contour = primitives2D.ClosedRoundedLineSegments2D(poly.points,
                                                       radius,
                                                       adapt_radius=True)
    offset_radius = []
    for prim in contour.primitives:
        if prim.__class__ is vm.core.Arc2D:
            offset_radius.append(prim.radius)

    inner_contour = contour.Offset(-min(offset_radius))
    outer_contour = inner_contour.Offset(-thickness_min)

    sides = primitives3D.ExtrudedProfile(origin,
                                         x,
                                         y,
                                         outer_contour, [inner_contour],
                                         height_bot_belt * extrusion_vector,
                                         alpha=alpha,
                                         name='sides')

    bottom = primitives3D.ExtrudedProfile(origin,
                                          x,
                                          y,
                                          outer_contour, [],
                                          -thickness_min * extrusion_vector,
                                          alpha=alpha,
                                          name='bottom')

    # Screw
    screw_holes_rl = inner_contour.Offset(-(thickness + screw_holes_clearance +
                                            0.5 * screw_holes_diameter))
示例#9
0
p1=vm.Point2D((0, 0))
p2=vm.Point2D((0.1, 0.))
p3=vm.Point2D((0.1, 0.2))
p4=vm.Point2D((0, 0.1))
p5=vm.Point2D((-0.01, 0.05))

#p6=vm.Point2D((0.1,0.3))

l1=primitives2D.RoundedLineSegments2D([p1, p2, p3, p4], {2: 0.01}, False)
l2=vm.Arc2D(p4, p5, p1)
c1=vm.Contour2D([l1, l2])
c2=c1.Rotation(vm.Point2D((0,0)),npy.pi,True)
c1.MPLPlot()
c2.MPLPlot()
c3=vm.Contour2D([c1, c2])
c3.MPLPlot()

po = vm.Point3D((0, 0, 0))
xp = vm.Vector3D((1, 0, 0))
yp = vm.Vector3D((0, 1, 0))


profile = primitives3D.ExtrudedProfile(po, xp, yp, c1, [], vm.Vector3D((0, 0.1, 0.2)))

model = vm.VolumeModel([('', [profile])])

#profile.MPLPlot((0,0,0),(1,0,0),(0,1,0))

#model.MPLPlot()

model.FreeCADExport('extrusion2')
示例#10
0
                                                   closed=True)
#hole = vm.Circle2D(p6, 0.01)
#inner_profile = primitives2D.RoundedLineSegments2D([p6, p7, p8], {0: }, closed = True)
l1 = vm.LineSegment2D(p6, p7)
l2 = vm.LineSegment2D(p7, p8)
l3 = vm.LineSegment2D(p8, p6)
c2 = vm.Contour2D([l1, l2, l3])

c1 = vm.Contour2D([outer_profile])
#c2 = vm.Contour2D([inner_profile])

po = vm.Point3D((0, 0, 0))
xp = vm.Vector3D((1, 0, 0))
yp = vm.Vector3D((0, 1, 0))
f, a = c1.MPLPlot()
c2.MPLPlot(a)

profile = primitives3D.ExtrudedProfile(po,
                                       xp,
                                       yp,
                                       c1, [c2],
                                       vm.Vector3D((0, 0, 0.2)),
                                       name='extrusion')

model = vm.VolumeModel([('profile', [profile])])

#profile.MPLPlot((0,0,0),(1,0,0),(0,1,0))

#model.MPLPlot()

model.FreeCADExport('extrusion')