def create(self, convertToSolid):
        self.checkDimensions()
        outer = self.createOuterPart()
        inner = self.createInnerPart()
        coupling = self.document.addObject("Part::Cut", "coupling")
        coupling.Base = outer
        coupling.Tool = inner

        if convertToSolid:
            # Before making a solid, recompute documents.
            self.document.recompute()
            # Now convert all parts to solid, and remove intermediate data.
            solid = Piping.toSolid(self.document, coupling, "coupling (solid)")
            Piping.removePartWithChildren(self.document, coupling)
            return solid
        return coupling
示例#2
0
 def create(self, convertToSolid):
     self.checkDimensions()
     outer = self.createOuterPart()
     inner = self.createInnerPart()
     tee = self.document.addObject("Part::Cut", "tee")
     tee.Base = outer
     tee.Tool = inner
     if convertToSolid:
         # Before making a solid, recompute documents. Otherwise there will be
         #    s = Part.Solid(Part.Shell(s))
         #    <class 'Part.OCCError'>: Shape is null
         # exception.
         self.document.recompute()
         # Now convert all parts to solid, and remove intermediate data.
         solid = Piping.toSolid(self.document, tee, "tee (solid)")
         # Remove previous (intermediate parts).
         Piping.removePartWithChildren(self.document, tee)
         return solid
     return tee
示例#3
0
    def create(self, convertToSolid):
        self.checkDimensions()
        outer = self.createOuterPart()
        inner = self.createInnerPart()
        # Remove inner part of the sockets.
        corner = self.document.addObject("Part::Cut", "Cut")
        corner.Base = outer
        corner.Tool = inner

        if convertToSolid:
            # Before making a solid, recompute documents. Otherwise there will be
            #    s = Part.Solid(Part.Shell(s))
            #    <class 'Part.OCCError'>: Shape is null
            # exception.
            self.document.recompute()
            # Now convert all parts to solid, and remove intermediate data.
            solid = Piping.toSolid(self.document, corner, "corner (solid)")
            Piping.removePartWithChildren(self.document, corner)
            return solid
        return corner
示例#4
0
    def create(self, convertToSolid):
        """Create a pipe which is a differences of two cilinders: outer cylinder - inner cylinder.

        :param convertToSolid: if true, the resulting part will be solid.
                if false, the resulting part will be a cut.
        :return resulting part.
        """
        self.checkDimensions()
        # Create outer cylinder.
        outer_cylinder = self.document.addObject("Part::Cylinder",
                                                 "OuterCylinder")
        outer_cylinder.Radius = self.OD / 2
        outer_cylinder.Height = self.H

        # Create inner cylinder. It is a little bit longer than the outer cylider in both ends.
        # This should prevent numerical problems when calculating difference
        # between the outer and innter cylinder.
        inner_cylinder = self.document.addObject("Part::Cylinder",
                                                 "InnerCylinder")
        inner_cylinder.Radius = self.OD / 2 - self.Thk
        inner_cylinder.Height = self.H * (1 + 2 * RELATIVE_EPSILON)
        inner_cylinder.Placement.Base = FreeCAD.Vector(
            0, 0, -self.H * RELATIVE_EPSILON)
        pipe = self.document.addObject("Part::Cut", "Pipe")
        pipe.Base = outer_cylinder
        pipe.Tool = inner_cylinder

        if convertToSolid:
            # Before making a solid, recompute documents. Otherwise there will be
            #    s = Part.Solid(Part.Shell(s))
            #    <class 'Part.OCCError'>: Shape is null
            # exception.
            self.document.recompute()
            # Now convert all parts to solid, and remove intermediate data.
            solid = Piping.toSolid(self.document, pipe, "pipe (solid)")
            Piping.removePartWithChildren(self.document, pipe)
            return solid
        return pipe
示例#5
0
 def create(self, convertToSolid):
     self.checkDimensions()
     """Create elbow."""
     # Create new group to put all the temporal data.
     group = self.document.addObject("App::DocumentObjectGroup",
                                     "elbow group")
     outer = self.createOuterPart(group)
     inner = self.createInnerPart(group)
     elbow = self.document.addObject("Part::Cut", "Elbow")
     elbow.Base = outer
     elbow.Tool = inner
     group.addObject(elbow)
     if convertToSolid:
         # Before making a solid, recompute documents. Otherwise there will be
         #    s = Part.Solid(Part.Shell(s))
         #    <class 'Part.OCCError'>: Shape is null
         # exception.
         self.document.recompute()
         # Now convert all parts to solid, and remove intermediate data.
         solid = Piping.toSolid(self.document, elbow, "elbow (solid)")
         Piping.removePartWithChildren(self.document, group)
         return solid
     return group