コード例 #1
0
 def create(self, partName, length, outputType):
     row = self.table.findPart(partName)
     if row is None:
         print("Part not found")
         return
     if outputType == Piping.OUTPUT_TYPE_PARTS or outputType == Piping.OUTPUT_TYPE_SOLID:
         pipe = Pipe(self.document)
         pipe.OD = parseQuantity(row["OD"])
         pipe.Thk = parseQuantity(row["Thk"])
         pipe.H = length
         part = pipe.create(outputType == Piping.OUTPUT_TYPE_SOLID)
         return part
     elif outputType == Piping.OUTPUT_TYPE_DODO_OR_FLAMINGO:
         # See Code in pipeCmd.makePipe in the Flamingo workbench.
         feature = self.document.addObject("Part::FeaturePython",
                                           "OSE-Pipe")
         DN = Piping.GetDnString(row)
         OD = parseQuantity(row["OD"])
         Thk = parseQuantity(row["Thk"])
         part = getDFPipe(feature, DN=DN, OD=OD, thk=Thk, H=length)
         feature.PRating = Piping.GetPressureRatingString(row)
         # Currently I do not know how to interprite table data as a profile.
         feature.Profile = ""
         if "PSize" in row.keys():
             feature.PSize = row["PSize"]
         # Workaround. Add ports before return. Otherwise the positioning is not working.
         feature.Ports = [
             FreeCAD.Vector(0, 0, 0),
             FreeCAD.Vector(0, 0, length)
         ]
         feature.ViewObject.Proxy = 0
         return part
コード例 #2
0
    def __init__(self, params):
        super(BaseDialog, self).__init__()
        self.params = params
        self.initUi()
        if Piping.HasFlamingoSupport() and not Piping.HasDodoSupport():
            self.labelFlamingoIsDepricated.show()
        else:
            self.labelFlamingoIsDepricated.hide()

        if Piping.HasDodoSupport() or Piping.HasFlamingoSupport():
            self.radioButtonDodoFlamingo.setEnabled(True)
        else:
            self.radioButtonDodoFlamingo.setEnabled(False)
コード例 #3
0
    def create(self, partNumber, outputType):
        row = self.table.findPart(partNumber)
        if row is None:
            print("Part not found")
            return

        dims = Dimensions()
        dims.BendAngle = parseQuantity(row["BendAngle"])
        dims.H = parseQuantity(row["H"])
        dims.J = parseQuantity(row["J"])
        dims.M = parseQuantity(row["M"])
        dims.POD = parseQuantity(row["POD"])
        dims.PThk = self.getPThk(row)

        if outputType == Piping.OUTPUT_TYPE_PARTS or outputType == Piping.OUTPUT_TYPE_SOLID:
            elbow = Elbow(self.document)
            elbow.dims = dims
            part = elbow.create(outputType == Piping.OUTPUT_TYPE_SOLID)
            part.Label = "OSE-Elbow"
            return part
        elif outputType == Piping.OUTPUT_TYPE_DODO_OR_FLAMINGO:
            # See Code in pipeCmd.makePipe in the Flamingo workbench.
            feature = self.document.addObject("Part::FeaturePython",
                                              "OSE-Elbow")
            import OsePiping.FlElbow as FlElbow
            builder = FlElbow.ElbowBuilder(self.document)
            builder.dims = dims
            part = builder.create(feature)
            feature.PRating = Piping.GetPressureRatingString(row)
            feature.PSize = self.getPSize(row)
            feature.ViewObject.Proxy = 0
            feature.PartNumber = partNumber
            return part
コード例 #4
0
    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
コード例 #5
0
    def create(self, partNumber, outputType):

        row = self.table.findPart(partNumber)
        if row is None:
            print("Part not found")
            return
        dims = Dimensions()

        dims.N = parseQuantity(row["N"])
        dims.L = parseQuantity(row["L"])
        dims.POD = parseQuantity(row["POD"])
        dims.POD1 = parseQuantity(row["POD1"])
        dims.PThk1 = self.getPThk1(row)

        if outputType == Piping.OUTPUT_TYPE_PARTS or outputType == Piping.OUTPUT_TYPE_SOLID:
            bushing = Bushing(self.document)
            bushing.dims = dims
            part = bushing.create(outputType == Piping.OUTPUT_TYPE_SOLID)
            part.Label = "OSE-Bushing"
            return part

        elif outputType == Piping.OUTPUT_TYPE_DODO_OR_FLAMINGO:
            # See Code in pipeCmd.makePipe in the Flamingo workbench.
            feature = self.document.addObject("Part::FeaturePython",
                                              "OSE-Bushing")
            import OsePiping.FlBushing as FlBushing
            builder = FlBushing.BushingBuilder(self.document)
            builder.dims = dims
            part = builder.create(feature)
            feature.PRating = Piping.GetPressureRatingString(row)
            feature.PSize = row["PSize"]  # What to do for multiple sizes?
            feature.ViewObject.Proxy = 0
            # feature.Label = partName # Part name must be unique, that is qhy use partNumber instead.
            feature.PartNumber = partNumber
            return part
コード例 #6
0
    def restoreInput(self):
        settings = QtCore.QSettings(
            BaseDialog.QSETTINGS_APPLICATION, self.params.settingsName)

        output = int(settings.value(
            "radioButtonsOutputType", Piping.OUTPUT_TYPE_SOLID))
        if output == Piping.OUTPUT_TYPE_DODO_OR_FLAMINGO  \
                and (Piping.HasDodoSupport() or Piping.HasFlamingoSupport()):
            self.radioButtonDodoFlamingo.setChecked(True)
        elif output == Piping.OUTPUT_TYPE_PARTS:
            self.radioButtonParts.setChecked(True)
        else:  # Default is solid. output == piping.OUTPUT_TYPE_SOLID
            self.radioButtonSolid.setChecked(True)

        self.selectPartByName(settings.value("LastSelectedPartNumber"))
        self.restoreAdditionalInput(settings)
コード例 #7
0
    def create(self, partNumber, outputType):
        row = self.table.findPart(partNumber)
        if row is None:
            print("Part not found")
            return

        dims = Dimensions()
        dims.G = parseQuantity(row["G"])
        dims.H = parseQuantity(row["H"])
        dims.M = parseQuantity(row["M"])
        dims.POD = parseQuantity(row["POD"])
        dims.PThk = self.getPThk(row)

        if outputType == Piping.OUTPUT_TYPE_PARTS or outputType == Piping.OUTPUT_TYPE_SOLID:
            corner = Corner(self.document)
            corner.dims = dims
            part = corner.create(outputType == Piping.OUTPUT_TYPE_SOLID)
            part.Label = "OSE-Corner"
            return part

        elif outputType == Piping.OUTPUT_TYPE_DODO_OR_FLAMINGO:
            feature = self.document.addObject(
                "Part::FeaturePython", "OSE-Corner")
            import OsePiping.FlCorner as FlCorner
            builder = FlCorner.CornerBuilder(self.document)
            builder.dims = dims
            part = builder.create(feature)
            feature.PRating = Piping.GetPressureRatingString(row)
            feature.PSize = self.getPSize(row)
            feature.ViewObject.Proxy = 0
            feature.PartNumber = partNumber
            return part
コード例 #8
0
 def __init__(self, params):
     super(BaseDialog, self).__init__()
     self.params = params
     self.initUi()
     if Piping.HasFlamingoSupport():
         self.radioButtonFlamingo.setEnabled(True)
     else:
         self.radioButtonFlamingo.setEnabled(False)
コード例 #9
0
def TestPartFromTable(partNumber, outputType):
    document = FreeCAD.activeDocument()
    table = Piping.CsvTable(DIMENSIONS_USED)
    table.load(CSV_TABLE_PATH)
    builder = CouplingFromTable(document, table)
    print("Creating part %s" % partNumber)
    builder.create(partNumber, outputType)
    document.recompute()
コード例 #10
0
ファイル: Tee.py プロジェクト: rkrenzler/ose-piping-workbench
 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
コード例 #11
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
コード例 #12
0
def TestTable():
    document = FreeCAD.activeDocument()
    table = Piping.CsvTable(DIMENSIONS_USED)
    table.load(CSV_TABLE_PATH)
    builder = CouplingFromTable(document, table)
    for i in range(0, len(table.data)):
        print("Selecting row %d" % i)
        partNumber = table.getPartKey(i)
        print("Creating part %s" % partNumber)
        builder.create(partNumber, Piping.OUTPUT_TYPE_SOLID)
        document.recompute()
コード例 #13
0
def TestTable():
    document = FreeCAD.activeDocument()
    table = Piping.CsvTable(DIMENSIONS_USED)
    table.load(CSV_TABLE_PATH)
    pipe = PipeFromTable(document, table)
    for i in range(0, len(table.data)):
        print("Selecting row %d" % i)
        partName = table.getPartName(i)
        print("Creating part %s" % partName)
        pipe.create(partName, parseQuantity("1m"), False)
        document.recompute()
コード例 #14
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
コード例 #15
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
コード例 #16
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")
     # ----------------------- Test code ---------------
     # self.createBentCylinder(self.document, group, self.M/2, self.M/2, self.alpha)
     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)")
         # Remove previous (intermediate parts).
         parts = Piping.nestedObjects(group)
         # Document.removeObjects can remove multple objects, when we use
         # parts directly. To prevent exceptions with deleted objects,
         # use the name list instead.
         names_to_remove = []
         for part in parts:
             if part.Name not in names_to_remove:
                 names_to_remove.append(part.Name)
         for name in names_to_remove:
             print("Deleting temporary objects %s." % name)
             self.document.removeObject(name)
         return solid
     return group
コード例 #17
0
ファイル: Tee.py プロジェクト: rkrenzler/ose-piping-workbench
    def create(self, partNumber, outputType):
        tee = Tee(self.document)
        row = self.table.findPart(partNumber)
        if row is None:
            print("Part not found {}".format(partNumber))
            return

        dims = Dimensions()
        dims.G = parseQuantity(row["G"])
        dims.G1 = parseQuantity(row["G1"])
        dims.G2 = parseQuantity(row["G2"])
        dims.H = parseQuantity(row["H"])
        dims.H1 = parseQuantity(row["H1"])
        dims.H2 = parseQuantity(row["H2"])
        dims.M = parseQuantity(row["M"])
        dims.M1 = parseQuantity(row["M1"])
        dims.M2 = parseQuantity(row["M2"])
        dims.POD = parseQuantity(row["POD"])
        dims.POD1 = parseQuantity(row["POD1"])
        dims.POD2 = parseQuantity(row["POD2"])
        dims.PThk = self.getPThk(row)
        dims.PThk1 = self.getPThk1(row)
        dims.PThk2 = self.getPThk2(row)

        if outputType == Piping.OUTPUT_TYPE_PARTS or outputType == Piping.OUTPUT_TYPE_SOLID:
            tee = Tee(self.document)
            tee.dims = dims
            part = tee.create(outputType == Piping.OUTPUT_TYPE_SOLID)
            part.Label = "OSE-Tee"
            return part

        elif outputType == Piping.OUTPUT_TYPE_DODO_OR_FLAMINGO:
            feature = self.document.addObject("Part::FeaturePython", "OSE-Tee")
            import OsePiping.FlTee as FlTee
            builder = FlTee.TeeBuilder(self.document)
            builder.dims = dims
            part = builder.create(feature)
            feature.PRating = Piping.GetPressureRatingString(row)
            feature.PSize = row["PSize"]  # What to do for multiple sizes?
            feature.ViewObject.Proxy = 0
            feature.PartNumber = partNumber
            return part
コード例 #18
0
    def create(self, partNumber, outputType):
        row = self.table.findPart(partNumber)
        if row is None:
            print("Part not found")
            return
        dims = Dimensions()
        dims.G = parseQuantity(row["G"])
        dims.G1 = parseQuantity(row["G1"])
        dims.H = parseQuantity(row["H"])
        dims.H1 = parseQuantity(row["H1"])
        dims.L = parseQuantity(row["L"])
        dims.L1 = parseQuantity(row["L1"])
        dims.M = parseQuantity(row["M"])
        dims.M1 = parseQuantity(row["M1"])
        dims.POD = parseQuantity(row["POD"])
        dims.POD1 = parseQuantity(row["POD1"])
        dims.PThk = CrossFromTable.getPThk(row)
        dims.PThk1 = CrossFromTable.getPThk1(row)

        if outputType == Piping.OUTPUT_TYPE_PARTS or outputType == Piping.OUTPUT_TYPE_SOLID:
            cross = Cross(self.document)
            cross.dims = dims
            part = cross.create(outputType == Piping.OUTPUT_TYPE_SOLID)
            part.Label = "OSE-Cross"
            return part
        elif outputType == Piping.OUTPUT_TYPE_FLAMINGO:
            # See Code in pipeCmd.makePipe in the Flamingo workbench.
            feature = self.document.addObject("Part::FeaturePython",
                                              "OSE-Cross")
            import OsePiping.FlCross as FlCross
            builder = FlCross.CrossBuilder(self.document)
            builder.dims = dims
            part = builder.create(feature)
            feature.PRating = Piping.GetPressureRatingString(row)
            feature.PSize = row["PSize"]  # What to do for multiple sizes?
            feature.ViewObject.Proxy = 0
            # feature.Label = partName # Part name must be unique, that is qhy use partNumber instead.
            feature.PartNumber = partNumber
            return part
コード例 #19
0
def GuiCheckTable(tablePath, dimensionsUsed):
    # Check if the CSV file exists.
    if os.path.isfile(tablePath) is False:
        text = "This tablePath requires %s  but this file does not exist." % (
            tablePath)
        msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Warning,
                                   "Creating of the part failed.", text)
        msgBox.exec_()
        exit(1)  # Error

    # FreeCAD.Console.PrintMessage("Trying to load CSV file with dimensions: %s\n"%tablePath)
    table = Piping.CsvTable(dimensionsUsed)
    table.load(tablePath)

    if table.hasValidData is False:
        text = 'Invalid %s.\n'\
            'It must contain columns %s.' % (
                tablePath, ", ".join(dimensionsUsed))
        msgBox = QtGui.QMessageBox(
            QtGui.QMessageBox.Warning, "Creating of the part failed.", text)
        msgBox.exec_()
        exit(1)  # Error

    return table
コード例 #20
0
    def create(self, partNumber, outputType):
        coupling = Coupling(self.document)
        row = self.table.findPart(partNumber)
        if row is None:
            print("Part not found")
            return

        dims = Dimensions()
        dims.L = parseQuantity(row["L"])
        dims.M = parseQuantity(row["M"])
        dims.M1 = parseQuantity(row["M1"])
        dims.N = parseQuantity(row["N"])
        dims.POD = parseQuantity(row["POD"])
        dims.POD1 = parseQuantity(row["POD1"])
        dims.PThk = self.getPThk(row)
        dims.PThk1 = self.getPThk1(row)

        if outputType == Piping.OUTPUT_TYPE_PARTS or outputType == Piping.OUTPUT_TYPE_SOLID:
            coupling = Coupling(self.document)
            coupling.dims = dims
            part = coupling.create(outputType == Piping.OUTPUT_TYPE_SOLID)
            part.Label = "OSE-Coupling"
            return part

        elif outputType == Piping.OUTPUT_TYPE_FLAMINGO:
            # See Code in pipeCmd.makePipe in the Flamingo workbench.
            feature = self.document.addObject("Part::FeaturePython", "OSE-Coupling")
            import OsePiping.FlCoupling as FlCoupling
            builder = FlCoupling.CouplingBuilder(self.document)
            builder.dims = dims
            part = builder.create(feature)
            feature.PRating = Piping.GetPressureRatingString(row)
            feature.PSize = self.getPSize(row)  # What to do for multiple sizes?
            feature.ViewObject.Proxy = 0
            feature.PartNumber = partNumber
            return part
コード例 #21
0
 def IsActive(self):
     """Here you can define if the command must be active or not (greyed) if certain conditions
     are met or not. This function is optional."""
     return (Piping.HasDodoSupport() or Piping.HasFlamingoSupport()) \
         and len(Gui.Selection.getSelectionEx()) >= 2 \
         and Modification.all_selected_parts_have_ports()
コード例 #22
0
 def checkDimensions(self):
     valid, msg = self.dims.isValid()
     if not valid:
         raise Piping.UnplausibleDimensions(msg)