def makePipe(propList=[], pos=None, Z=None, name="Tubo"): '''add a Pipe object makePipe(propList,pos,Z); propList is one optional list with 4 elements: DN (string): nominal diameter OD (float): outside diameter thk (float): shell thickness H (float): length of pipe Default is "DN50 (SCH-STD)" pos (vector): position of insertion; default = 0,0,0 Z (vector): orientation: default = 0,0,1 Remember: property PRating must be defined afterwards ''' if pos == None: pos = FreeCAD.Vector(0, 0, 0) if Z == None: Z = FreeCAD.Vector(0, 0, 1) pos a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", name) if len(propList) == 4: pipeFeatures.Pipe(a, *propList) else: pipeFeatures.Pipe(a) a.ViewObject.Proxy = 0 a.Placement.Base = pos rot = FreeCAD.Rotation(FreeCAD.Vector(0, 0, 1), Z) a.Placement.Rotation = rot.multiply(a.Placement.Rotation) return a
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_FLAMINGO: # See Code in pipeCmd.makePipe in the Flamingo workbench. feature = self.document.addObject("Part::FeaturePython", "OSE-Pipe") import pipeFeatures DN = Piping.GetDnString(row) OD = parseQuantity(row["OD"]) Thk = parseQuantity(row["Thk"]) part = pipeFeatures.Pipe(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
def getDFPipe(obj, DN, OD, thk, H): """Get pipe features from Dodo or from Flamingo workbench. """ try: import pFeatures FreeCAD.Console.PrintMessage("Creating Dodo pipe.") return pFeatures.Pipe(obj, DN=DN, OD=OD, thk=thk, H=H) except ModuleNotFoundError: FreeCAD.Console.PrintMessage( "Dodo workbench is not found. I will use Flamingo instead.") import pipeFeatures return pipeFeatures.Pipe(obj, DN=DN, OD=OD, thk=thk, H=H)