Exemplo n.º 1
0
 def dbgSphere(self, pt):
     """
     TODO : know why sphere is appended to the model, if no reason than remove sphere from all the cad files (by Anand Swaroop)
     :param pt: pt of origin for the nut bol placement
     :return: returns the sphere
     """
     return BRepPrimAPI_MakeSphere(getGpPt(pt), 0.1).Shape()
Exemplo n.º 2
0
    def create_model(self):

        edges = makeEdgesFromPoints(self.points)
        wire = makeWireFromEdges(edges)
        aFace = makeFaceFromWire(wire)
        extrudeDir = -self.T * self.shaftDir  # extrudeDir is a numpy array
        boltHead = makePrismFromFace(aFace, extrudeDir)
        cylOrigin = self.origin
        boltCylinder = BRepPrimAPI_MakeCylinder(
            gp_Ax2(getGpPt(cylOrigin), getGpDir(self.shaftDir)), self.r,
            self.H).Shape()

        whole_Bolt = BRepAlgoAPI_Fuse(boltHead, boltCylinder).Shape()

        return whole_Bolt
Exemplo n.º 3
0
    def create_model(self):

        edges = makeEdgesFromPoints(self.points)
        wire = makeWireFromEdges(edges)
        aFace = makeFaceFromWire(wire)
        extrudeDir = self.T * self.wDir  # extrudeDir is a numpy array
        prism = makePrismFromFace(aFace, extrudeDir)

        cylOrigin = self.sec_origin
        innerCyl = BRepPrimAPI_MakeCylinder(
            gp_Ax2(getGpPt(cylOrigin), getGpDir(self.wDir)), self.r1,
            self.H).Shape()

        result_shape = BRepAlgoAPI_Cut(prism, innerCyl).Shape()

        return result_shape
Exemplo n.º 4
0
    def create_model(self, rotate_angle=None):
        Pnt = getGpPt(self.sec_origin)
        edges = makeEdgesFromPoints(self.points)
        wire = makeWireFromEdges(edges)
        aFace = makeFaceFromWire(wire)
        extrudeDir = self.L * (self.wDir)  # extrudeDir is a numpy array
        if rotate_angle == None:
            prism1 = makePrismFromFace(aFace, extrudeDir)
        else:
            prism = makePrismFromFace(aFace, extrudeDir)
            trns = gp_Trsf()
            angle = radians(rotate_angle)
            trns.SetRotation(gp_OX(), angle)
            brep_trns = BRepBuilderAPI_Transform(prism, trns, False)
            brep_trns.Build()
            prism1 = brep_trns.Shape()

        return prism1
Exemplo n.º 5
0
 def dbgSphere(self, pt):
     return BRepPrimAPI_MakeSphere(getGpPt(pt), 0.1).Shape()
Exemplo n.º 6
0
    def create_model(self):

        ######################################################
        edges = []
        if self.R2 == 0.0 or self.R1 == 0.0:
            self.a3 = self.a4 = self.a5
            edge1 = make_edge(getGpPt(self.a1), getGpPt(self.a2))
            edges.append(edge1)
            edge2 = make_edge(getGpPt(self.a2), getGpPt(self.a3))
            edges.append(edge2)
            edge3 = make_edge(getGpPt(self.a3), getGpPt(self.a6))
            edges.append(edge3)
            # arc2 = GC_MakeArcOfCircle(getGpPt(self.a6), getGpPt(self.a7), getGpPt(self.a8))
            # edge4 = make_edge(arc2.Value())
            # edges.append(edge4)
            # edge5 = make_edge(getGpPt(self.a8), getGpPt(self.a9))
            # edges.append(edge5)
            # edge6 = make_edge(getGpPt(self.a9), getGpPt(self.a12))
            # edges.append(edge6)
            # edge7 = make_edge(getGpPt(self.a12), getGpPt(self.a1))
            # edges.append(edge7)
            edge4 = make_edge(getGpPt(self.a6), getGpPt(self.a9))
            edges.append(edge4)
            edge5 = make_edge(getGpPt(self.a9), getGpPt(self.a12))
            edges.append(edge5)
            edge6 = make_edge(getGpPt(self.a12), getGpPt(self.a1))
            edges.append(edge6)

        else:
            edge1 = make_edge(getGpPt(self.a1), getGpPt(self.a2))
            edges.append(edge1)
            edge2 = make_edge(getGpPt(self.a2), getGpPt(self.a3))
            edges.append(edge2)
            arc1 = GC_MakeArcOfCircle(getGpPt(self.a3), getGpPt(self.a4),
                                      getGpPt(self.a5))
            edge3 = make_edge(arc1.Value())
            edges.append(edge3)
            edge4 = make_edge(getGpPt(self.a5), getGpPt(self.a6))
            edges.append(edge4)
            arc2 = GC_MakeArcOfCircle(getGpPt(self.a6), getGpPt(self.a7),
                                      getGpPt(self.a8))
            edge5 = make_edge(arc2.Value())
            edges.append(edge5)
            edge6 = make_edge(getGpPt(self.a8), getGpPt(self.a9))
            edges.append(edge6)
            arc3 = GC_MakeArcOfCircle(getGpPt(self.a9), getGpPt(self.a10),
                                      getGpPt(self.a11))
            edge7 = make_edge(arc3.Value())
            edges.append(edge7)
            edge8 = make_edge(getGpPt(self.a11), getGpPt(self.a12))
            edges.append(edge8)
            edge9 = make_edge(getGpPt(self.a12), getGpPt(self.a1))
            edges.append(edge9)

        wire = makeWireFromEdges(edges)
        aFace = makeFaceFromWire(wire)
        extrudeDir = self.L * self.wDir  # extrudeDir is a numpy array
        prism = makePrismFromFace(aFace, extrudeDir)
        mkFillet = BRepFilletAPI_MakeFillet(prism)
        anEdgeExplorer = TopExp_Explorer(prism, TopAbs_EDGE)
        while anEdgeExplorer.More():
            aEdge = topods.Edge(anEdgeExplorer.Current())
            mkFillet.Add(self.T / 17., aEdge)
            anEdgeExplorer.Next()

        prism = mkFillet.Shape()
        return prism
Exemplo n.º 7
0
    def createEdges(self):

        edges = []
        # Join points a,b
        edge = make_edge(getGpPt(self.a), getGpPt(self.b))
        edges.append(edge)
        # # Join points b1 and b2
        # cirl = gp_Circ(gp_Ax2(getGpPt(self.o1), getGpDir(self.wDir)), self.R1)
        # edge = make_edge(cirl,getGpPt(self.b2), getGpPt(self.b1))
        # edges.append(edge)
        # Join points b and c2
        edge = make_edge(getGpPt(self.b), getGpPt(self.c2))
        edges.append(edge)
        # join points c2 and c1
        cirl2 = gp_Circ(gp_Ax2(getGpPt(self.o2), getGpDir(self.wDir)), self.R1)
        edge = make_edge(cirl2, getGpPt(self.c1), getGpPt(self.c2))
        edges.append(edge)
        # Join points c1 and d
        edge = make_edge(getGpPt(self.c1), getGpPt(self.d))
        edges.append(edge)
        # Join points d and a
        edge = make_edge(getGpPt(self.d), getGpPt(self.a))
        edges.append(edge)

        return edges