Exemple #1
0
 def Activated (self):
   import frameCmd, pipeCmd
   if len(frameCmd.beams())>1:
     p1,p2=frameCmd.beams()[:2]
     try:
       P=frameCmd.intersectionCLines(p1,p2)
       com1=p1.Shape.Solids[0].CenterOfMass
       com2=p2.Shape.Solids[0].CenterOfMass
       v1=P-com1
       v2=com2-P
       curves=[e for e in FreeCADGui.Selection.getSelection() if hasattr(e,'PType') and hasattr(e,'BendAngle')]
       if curves:
         FreeCAD.ActiveDocument.openTransaction('Place one curve')
         pipeCmd.placeoTherElbow(curves[0],v1,v2,P)
         FreeCAD.ActiveDocument.recompute() # recompute for the elbow
         port1,port2=pipeCmd.portsPos(curves[0])
         if (com1-port1).Length<(com1-port2).Length:
           frameCmd.extendTheBeam(p1,port1)
           frameCmd.extendTheBeam(p2,port2)
         else:
           frameCmd.extendTheBeam(p1,port2)
           frameCmd.extendTheBeam(p2,port1)
         FreeCAD.ActiveDocument.recompute() # recompute for the pipes
         FreeCAD.ActiveDocument.commitTransaction()
       else:
         FreeCAD.Console.PrintError('Select at least one elbow')
     except:
       FreeCAD.Console.PrintError('Intersection point not found\n')
   else:
     FreeCAD.Console.PrintError('Select two intersecting pipes\n')
Exemple #2
0
 def Activated(self):
     import frameCmd, pipeCmd
     if len(frameCmd.beams()) > 1:
         p1, p2 = frameCmd.beams()[:2]
         try:
             P = frameCmd.intersectionCLines(p1, p2)
             com1 = p1.Shape.Solids[0].CenterOfMass
             com2 = p2.Shape.Solids[0].CenterOfMass
             v1 = P - com1
             v2 = com2 - P
             curves = [
                 e for e in FreeCADGui.Selection.getSelection()
                 if hasattr(e, 'PType') and hasattr(e, 'BendAngle')
             ]
             if curves:
                 FreeCAD.ActiveDocument.openTransaction('Place one curve')
                 pipeCmd.placeoTherElbow(curves[0], v1, v2, P)
                 FreeCAD.ActiveDocument.recompute(
                 )  # recompute for the elbow
                 port1, port2 = pipeCmd.portsPos(curves[0])
                 if (com1 - port1).Length < (com1 - port2).Length:
                     frameCmd.extendTheBeam(p1, port1)
                     frameCmd.extendTheBeam(p2, port2)
                 else:
                     frameCmd.extendTheBeam(p1, port2)
                     frameCmd.extendTheBeam(p2, port1)
                 FreeCAD.ActiveDocument.recompute(
                 )  # recompute for the pipes
                 FreeCAD.ActiveDocument.commitTransaction()
             else:
                 FreeCAD.Console.PrintError('Select at least one elbow')
         except:
             FreeCAD.Console.PrintError('Intersection point not found\n')
     else:
         FreeCAD.Console.PrintError('Select two intersecting pipes\n')
Exemple #3
0
 def accept(self):            # extend
   if self.target!=None and len(frameCmd.beams())>0:
     FreeCAD.activeDocument().openTransaction('Extend beam')
     for beam in frameCmd.beams():
       frameCmd.extendTheBeam(beam,self.target)
     FreeCAD.activeDocument().recompute()
     FreeCAD.activeDocument().commitTransaction()
Exemple #4
0
 def accept(self):  # extend
     if self.target != None and len(frameCmd.beams()) > 0:
         FreeCAD.activeDocument().openTransaction('Extend beam')
         for beam in frameCmd.beams():
             frameCmd.extendTheBeam(beam, self.target)
         FreeCAD.activeDocument().recompute()
         FreeCAD.activeDocument().commitTransaction()
Exemple #5
0
def makeElbowBetweenThings(thing1=None, thing2=None, propList=None):
    '''
  makeElbowBetweenThings(thing1, thing2, propList=None):
  Place one elbow at the intersection of thing1 and thing2.
  Things can be any combination of intersecting beams, pipes or edges.
  If nothing is passed as argument, the function attempts to take the
  first two edges selected in the view.
  propList is one optional list with 5 elements:
    DN (string): nominal diameter
    OD (float): outside diameter
    thk (float): shell thickness
    BA (float): bend angle - that will be recalculated! -
    BR (float): bend radius
  Default is "DN50 (SCH-STD)"
  Remember: property PRating must be defined afterwards
  '''
    if not (thing1 and thing2):
        thing1, thing2 = frameCmd.edges()[:2]
    P = frameCmd.intersectionCLines(thing1, thing2)
    directions = list()
    try:
        for thing in [thing1, thing2]:
            if frameCmd.beams([thing]):
                directions.append(
                    rounded(
                        (frameCmd.beamAx(thing).multiply(thing.Height / 2) +
                         thing.Placement.Base) - P))
            elif hasattr(thing, 'ShapeType') and thing.ShapeType == 'Edge':
                directions.append(rounded(thing.CenterOfMass - P))
    except:
        return None
    ang = 180 - degrees(directions[0].getAngle(directions[1]))
    if ang == 0 or ang == 180: return None
    if not propList:
        propList = ["DN50", 60.3, 3.91, ang, 45.24]
    else:
        propList[3] = ang
    elb = makeElbow(propList, P,
                    directions[0].negative().cross(directions[1].negative()))
    # mate the elbow ends with the pipes or edges
    b = frameCmd.bisect(directions[0], directions[1])
    elbBisect = rounded(frameCmd.beamAx(elb, FreeCAD.Vector(
        1, 1, 0)))  #if not rounded, fail in plane xz
    rot = FreeCAD.Rotation(elbBisect, b)
    elb.Placement.Rotation = rot.multiply(elb.Placement.Rotation)
    # trim the adjacent tubes
    #FreeCAD.activeDocument().recompute() # may delete this row?
    portA = elb.Placement.multVec(elb.Ports[0])
    portB = elb.Placement.multVec(elb.Ports[1])
    for tube in [t for t in [thing1, thing2] if frameCmd.beams([t])]:
        vectA = tube.Shape.Solids[0].CenterOfMass - portA
        vectB = tube.Shape.Solids[0].CenterOfMass - portB
        if frameCmd.isParallel(vectA, frameCmd.beamAx(tube)):
            frameCmd.extendTheBeam(tube, portA)
        else:
            frameCmd.extendTheBeam(tube, portB)
    return elb
Exemple #6
0
 def getProfile(self):
   if self.current:
     if frameCmd.beams():
       self.current.Profile=frameCmd.beams()[0].Base
     elif self.sectList.selectedItems():
       prof= FreeCAD.ActiveDocument.getObjectsByLabel(self.sectList.selectedItems()[0].text())[0]
       if prof.Shape.ShapeType=='Wire' and self.cb2.isChecked():
         prof.Placement.move(FreeCAD.Vector(0,0,0)-prof.Shape.CenterOfMass)
       prof.Placement.Rotation=FreeCAD.Base.Rotation()
       self.current.Profile=prof
Exemple #7
0
 def trim(self):
   if len(frameCmd.beams())==1:
     pipe=frameCmd.beams()[0]
     comPipeEdges=[e.CenterOfMass for e in pipe.Shape.Edges]
     eds=[e for e in frameCmd.edges() if not e.CenterOfMass in comPipeEdges]
     FreeCAD.activeDocument().openTransaction('Trim pipes')
     for edge in eds:
       frameCmd.extendTheBeam(frameCmd.beams()[0],edge)
     FreeCAD.activeDocument().commitTransaction()
     FreeCAD.activeDocument().recompute()
   else:
     FreeCAD.Console.PrintError("Wrong selection\n")
 def getProfile(self):
     if self.current:
         if frameCmd.beams():
             self.current.Profile = frameCmd.beams()[0].Base
         elif self.sectList.selectedItems():
             prof = FreeCAD.ActiveDocument.getObjectsByLabel(
                 self.sectList.selectedItems()[0].text())[0]
             if prof.Shape.ShapeType == 'Wire' and self.cb2.isChecked():
                 prof.Placement.move(
                     FreeCAD.Vector(0, 0, 0) - prof.Shape.CenterOfMass)
             prof.Placement.Rotation = FreeCAD.Base.Rotation()
             self.current.Profile = prof
Exemple #9
0
 def selectAction(self):
   if self.labTail:
     self.labTail.removeLabel()
     self.labTail=None
   self.L=frameCmd.getDistance()
   if self.L:
     self.form.edit1.setText("%.3f"%self.L)
   elif frameCmd.beams():
     beam=frameCmd.beams()[0]
     self.L=float(beam.Height)
     self.form.edit1.setText("%.3f"%self.L)
   else:
     self.form.edit1.setText('') 
   self.form.slider.setValue(0)
   self.writeTail()
Exemple #10
0
 def selectAction(self):
     if self.labTail:
         self.labTail.removeLabel()
         self.labTail = None
     self.L = frameCmd.getDistance()
     if self.L:
         self.form.edit1.setText("%.3f" % self.L)
     elif frameCmd.beams():
         beam = frameCmd.beams()[0]
         self.L = float(beam.Height)
         self.form.edit1.setText("%.3f" % self.L)
     else:
         self.form.edit1.setText('')
     self.form.slider.setValue(0)
     self.writeTail()
Exemple #11
0
def laydownTheTube(pipe=None, refFace=None, support=None):
    '''
  laydownTheTube(pipe=None, refFace=None, support=None)
  Makes one pipe touch one face if the center-line is parallel to it.
  If support is not None, support is moved towards pipe.
  '''
    if not (pipe and refFace):  # without argument take from selection set
        refFace = [
            f for f in frameCmd.faces() if type(f.Surface) == Part.Plane
        ][0]
        pipe = [p for p in frameCmd.beams() if hasattr(p, 'OD')][0]
    try:
        if type(refFace.Surface) == Part.Plane and frameCmd.isOrtho(
                refFace, frameCmd.beamAx(pipe)) and hasattr(pipe, 'OD'):
            dist = rounded(
                refFace.normalAt(0, 0).multiply(
                    refFace.normalAt(0, 0).dot(pipe.Placement.Base -
                                               refFace.CenterOfMass) -
                    float(pipe.OD) / 2))
            if support:
                support.Placement.move(dist)
            else:
                pipe.Placement.move(dist.multiply(-1))
        else:
            FreeCAD.Console.PrintError(
                'Face is not flat or not parallel to axis of pipe\n')
    except:
        FreeCAD.Console.PrintError('Wrong selection\n')
Exemple #12
0
def breakTheTubes(point, pipes=[], gap=0):
    '''
  breakTheTube(point,pipes=[],gap=0)
  Breaks the "pipes" at "point" leaving a "gap".
  '''
    pipes2nd = list()
    if not pipes:
        pipes = [p for p in frameCmd.beams() if isPipe(p)]
    if pipes:
        for pipe in pipes:
            if point < float(
                    pipe.Height) and gap < (float(pipe.Height) - point):
                propList = [
                    pipe.PSize,
                    float(pipe.OD),
                    float(pipe.thk),
                    float(pipe.Height) - point - gap
                ]
                pipe.Height = point
                Z = frameCmd.beamAx(pipe)
                pos = pipe.Placement.Base + Z * (float(pipe.Height) + gap)
                pipe2nd = makePipe(propList, pos, Z)
                pipes2nd.append(pipe2nd)
        #FreeCAD.activeDocument().recompute()
    return pipes2nd
 def trim(self):
     FreeCAD.ActiveDocument.openTransaction('Trim FB')
     for target in self.targets:
         for b in frameCmd.beams():
             if hasattr(b, 'tailOffset') and hasattr(b, 'headOffset'):
                 edge = b.Support[0][0].Shape.getElement(b.Support[0][1][0])
                 ax = edge.tangentAt(
                     0).normalize()  #frameCmd.beamAx(b).normalize()
                 tail = edge.valueAt(0)  #b.Placement.Base
                 head = edge.valueAt(
                     edge.LastParameter)  #tail+ax*float(b.Height)
                 if target.ShapeType == "Vertex":
                     P = target.Point
                 elif target.ShapeType == "Face" and not frameCmd.isOrtho(
                         target, ax):
                     P = frameCmd.intersectionPlane(tail, ax, target)
                 elif hasattr(target, "CenterOfMass"):
                     P = target.CenterOfMass
                 else:
                     P = None
                 if P:
                     #print P
                     #print ax.Length
                     deltaTail = (P - tail).dot(ax)
                     deltaHead = (P - head).dot(ax)
                     #print "D-tail = %.1f; D-head = %.1f" %(deltaTail,deltaHead)
                     if abs(deltaTail) < abs(deltaHead):
                         b.tailOffset = -deltaTail
                     else:
                         b.headOffset = deltaHead
     refresh()
     FreeCAD.ActiveDocument.commitTransaction()
Exemple #14
0
 def stretchTail(self):
   beams=frameCmd.beams()
   if beams:
     L=float(beams[0].Height)/2
     ext=L*(self.form.sliTail.value()/100.0)
     self.form.editTail.setText("%.3f" %ext)
     self.changeTailOffset()
Exemple #15
0
 def Activated(self):
     import pipeCmd, frameCmd
     FreeCAD.activeDocument().openTransaction('Flatten')
     if len(frameCmd.beams()) >= 2:
         pipeCmd.flattenTheTube()
     FreeCAD.activeDocument().recompute()
     FreeCAD.activeDocument().commitTransaction()
Exemple #16
0
 def stretchHead(self):
   beams=frameCmd.beams()
   if beams:
     L=float(beams[0].Height)/2
     ext=L*(self.form.sliHead.value()/100.0)
     self.form.editHead.setText("%.3f" %ext)
     self.changeHeadOffset()
Exemple #17
0
 def trim(self):
   FreeCAD.ActiveDocument.openTransaction('Trim FB')
   for target in self.targets:
     for b in frameCmd.beams():
       if hasattr(b,'tailOffset') and hasattr(b,'headOffset'):
         edge=b.Support[0][0].Shape.getElement(b.Support[0][1][0])
         ax=edge.tangentAt(0).normalize() #frameCmd.beamAx(b).normalize()
         tail=edge.valueAt(0) #b.Placement.Base
         head=edge.valueAt(edge.LastParameter) #tail+ax*float(b.Height)
         if target.ShapeType=="Vertex":
           P=target.Point
         elif target.ShapeType=="Face" and not frameCmd.isOrtho(target,ax):
           P=frameCmd.intersectionPlane(tail,ax,target)
         elif hasattr(target,"CenterOfMass"):
           P=target.CenterOfMass
         else: 
           P=None
         if P:
           #print P
           #print ax.Length
           deltaTail=(P-tail).dot(ax)
           deltaHead=(P-head).dot(ax)
           #print "D-tail = %.1f; D-head = %.1f" %(deltaTail,deltaHead)
           if abs(deltaTail)<abs(deltaHead):
             b.tailOffset=-deltaTail
           else:
             b.headOffset=deltaHead
   refresh()
   FreeCAD.ActiveDocument.commitTransaction()
Exemple #18
0
def flattenTheTube(obj=None, v1=None, v2=None, X=None):
    '''
  flattenTheTube(obj=None,v1=None,v2=None, X=None)
  Put obj in the same plane defined by vectors v1 and v2 and move it to X.
    obj: the object to be rotated
    v1, v2: the vectors of the plane
    X: the Placement.Base
  If no parameter is defined: v1, v2 are the axis of the first two beams 
  in the selections set, X is their intersection and obj is the first other
  object in the selection set. 
  '''
    if None in [obj, v1, v2]:
        try:
            sel = FreeCADGui.Selection.getSelection()
            t1, t2 = frameCmd.beams()[:2]
            v1 = frameCmd.beamAx(t1)
            v2 = frameCmd.beamAx(t2)
            sel.remove(t1)
            sel.remove(t2)
            obj = sel[0]
            X = frameCmd.intersectionCLines(t1, t2)
        except:
            FreeCAD.Console.PrintError('Not enough arguments\n')
            return
    obj.Placement.Rotation = FreeCAD.Rotation(
        frameCmd.beamAx(obj), v1.cross(v2)).multiply(obj.Placement.Rotation)
    obj.Placement.Base = X
 def stretchHead(self):
     beams = frameCmd.beams()
     if beams:
         L = float(beams[0].Height) / 2
         ext = L * (self.form.sliHead.value() / 100.0)
         self.form.editHead.setText("%.3f" % ext)
         self.changeHeadOffset()
 def refresh(self):
     obj = findFB(frameCmd.beams()[0].Name)
     if not obj:
         obj = findFB(baseName=FreeCADGui.Selection.getSelection()[0])
     if obj: obj.Proxy.redraw(obj)
     FreeCAD.ActiveDocument.recompute()
     FreeCAD.ActiveDocument.recompute()
 def stretchTail(self):
     beams = frameCmd.beams()
     if beams:
         L = float(beams[0].Height) / 2
         ext = L * (self.form.sliTail.value() / 100.0)
         self.form.editTail.setText("%.3f" % ext)
         self.changeTailOffset()
 def changeAngle(self):
     for beam in frameCmd.beams():
         if hasattr(beam, 'spin'):
             FB = findFB(beam.Name)
             beam.spin = float(self.form.editAngle.text())
             FB.touch()
     FreeCAD.ActiveDocument.recompute()
     FreeCAD.ActiveDocument.recompute()
 def changeTailOffset(self):
     for beam in frameCmd.beams():
         if hasattr(beam, 'tailOffset'):
             beam.tailOffset = float(self.form.editTail.text())
             FB = findFB(beam.Name)
             FB.touch()
     FreeCAD.ActiveDocument.recompute()
     FreeCAD.ActiveDocument.recompute()
Exemple #24
0
 def changeAngle(self):
   for beam in frameCmd.beams():
     if hasattr(beam,'spin'): 
       FB=findFB(beam.Name)
       beam.spin=float(self.form.editAngle.text())
       FB.touch()
   FreeCAD.ActiveDocument.recompute()
   FreeCAD.ActiveDocument.recompute()
Exemple #25
0
 def changeTailOffset(self):
   for beam in frameCmd.beams():
     if hasattr(beam,'tailOffset'): 
       beam.tailOffset=float(self.form.editTail.text())
       FB=findFB(beam.Name)
       FB.touch()
   FreeCAD.ActiveDocument.recompute()
   FreeCAD.ActiveDocument.recompute()
Exemple #26
0
 def Activated(self):
   import FreeCAD, frameCmd
   if len(frameCmd.beams())>1:
     FreeCAD.activeDocument().openTransaction('rotJoin')
     frameCmd.rotjoinTheBeam()
     FreeCAD.activeDocument().recompute()
     FreeCAD.activeDocument().commitTransaction()
   else:
     FreeCAD.Console.PrintError('Please select two edges of beams before\n')
Exemple #27
0
 def purge(self,fp):
   group=FreeCAD.activeDocument().getObjectsByLabel(fp.Group)[0]
   beams2purge=frameCmd.beams(group.OutList)
   if beams2purge:
     for b in beams2purge:
       profiles=b.OutList
       FreeCAD.ActiveDocument.removeObject(b.Name)
       for p in profiles:
         FreeCAD.ActiveDocument.removeObject(p.Name)
 def purge(self, fp):
     group = FreeCAD.activeDocument().getObjectsByLabel(fp.Group)[0]
     beams2purge = frameCmd.beams(group.OutList)
     if beams2purge:
         for b in beams2purge:
             profiles = b.OutList
             FreeCAD.ActiveDocument.removeObject(b.Name)
             for p in profiles:
                 FreeCAD.ActiveDocument.removeObject(p.Name)
Exemple #29
0
 def accept(self):
     faces = frameCmd.faces()
     beams = frameCmd.beams()
     if len(faces) == len(beams) > 0 and self.faceRef:
         FreeCAD.activeDocument().openTransaction('AlignFlange')
         for i in range(len(beams)):
             frameCmd.rotTheBeam(beams[i], self.faceRef, faces[i])
         FreeCAD.activeDocument().recompute()
         FreeCAD.activeDocument().commitTransaction()
Exemple #30
0
 def Activated (self):
   import pipeCmd, frameCmd
   from Part import Plane
   refFace=[f for f in frameCmd.faces() if type(f.Surface)==Plane][0]
   FreeCAD.activeDocument().openTransaction('Lay-down the pipe')
   for b in frameCmd.beams():
     if pipeCmd.isPipe(b):
       pipeCmd.laydownTheTube(b,refFace)
   FreeCAD.activeDocument().recompute()
   FreeCAD.activeDocument().commitTransaction()
Exemple #31
0
 def Activated(self):
     import pipeCmd, frameCmd
     from Part import Plane
     refFace = [f for f in frameCmd.faces() if type(f.Surface) == Plane][0]
     FreeCAD.activeDocument().openTransaction('Lay-down the pipe')
     for b in frameCmd.beams():
         if pipeCmd.isPipe(b):
             pipeCmd.laydownTheTube(b, refFace)
     FreeCAD.activeDocument().recompute()
     FreeCAD.activeDocument().commitTransaction()
 def Activated(self):
     import FreeCAD, frameCmd
     if len(frameCmd.beams()) > 1:
         FreeCAD.activeDocument().openTransaction('rotJoin')
         frameCmd.rotjoinTheBeam()
         FreeCAD.activeDocument().recompute()
         FreeCAD.activeDocument().commitTransaction()
     else:
         FreeCAD.Console.PrintError(
             'Please select two edges of beams before\n')
Exemple #33
0
 def getL(self):
   l=[p.Height for p in frameCmd.beams() if pipeCmd.isPipe(p)]
   if l:
     refL=min(l)
     self.lab0.setText(str(refL))
     self.refL=float(refL)
     self.edit1.setText("%.2f" %(self.refL*self.slider.value()/100.0))
   else:
     self.lab0.setText('<reference>')
     self.refL=0.0
     self.edit1.setText(str(self.slider.value())+'%')
Exemple #34
0
 def onPushButton1(self):
   from math import pi, degrees
   import frameCmd
   try:
     obj=self.Selection.getSelection()[0]
     self.labName.setText(obj.Label)
     self.labBaseVal.setText(str("P = %.1f,%.1f,%.1f"%tuple(obj.Placement.Base)))
     self.labRotAng.setText(str("%.2f " %(degrees(obj.Placement.Rotation.Angle))))
     ax=obj.Placement.Rotation.Axis
     self.labRotAx.setText(str("v = (%(x).2f,%(y).2f,%(z).2f)" %{'x':ax.x,'y':ax.y,'z':ax.z}))
     shapes=[y for x in self.Selection.getSelectionEx() for y in x.SubObjects if hasattr(y,'ShapeType')]
     if len(shapes)==1:
       sub=shapes[0]
       if sub.ShapeType=='Edge':
         if sub.curvatureAt(0)==0:
           self.labSubObj.setText(sub.ShapeType+':\tL = %.1f mm' %sub.Length)
         else:
           x,y,z=sub.centerOfCurvatureAt(0)
           d=2/sub.curvatureAt(0)
           self.labSubObj.setText(sub.ShapeType+':\tD = %.1f mm\n\tC = %.1f,%.1f,%.1f' %(d,x,y,z))
       elif sub.ShapeType=='Face':
         self.labSubObj.setText(sub.ShapeType+':\tA = %.1f mm2' %sub.Area)
       elif sub.ShapeType=='Vertex':
         self.labSubObj.setText(sub.ShapeType+': pos = (%(x).1f,%(y).1f,%(z).1f)' %{'x':sub.X,'y':sub.Y,'z':sub.Z})
     elif len(shapes)>1:
       self.labSubObj.setText(shapes[0].ShapeType+' to '+shapes[1].ShapeType+': distance = %.1f mm' %(shapes[0].distToShape(shapes[1])[0]))
     else:
       self.labSubObj.setText(' ')
     if len(frameCmd.beams())==1:
       b=frameCmd.beams()[0]
       self.labBeam.setText(b.Label+":\tL=%.2f"%(b.Height))
       self.labProfile.setText("Profile: "+b.Profile)
     elif len(frameCmd.beams())>1:
       b1,b2=frameCmd.beams()[:2]
       self.labBeam.setText(b1.Label+"^"+b2.Label+": %.2f"%(degrees(frameCmd.beamAx(b1).getAngle(frameCmd.beamAx(b2)))))
       self.labProfile.setText("")
     else:
       self.labBeam.setText("")
       self.labProfile.setText("")
   except:
     pass
Exemple #35
0
def extendTheTubes2intersection(pipe1=None,pipe2=None,both=True):
  '''
  Does what it says; also with beams.
  If arguments are None, it picks the first 2 selected beams().
  '''
  if not (pipe1 and pipe2):
    try:
      pipe1,pipe2=frameCmd.beams()[:2]
    except:
      FreeCAD.Console.PrintError('Insufficient arguments for extendTheTubes2intersection\n')
  P=frameCmd.intersectionCLines(pipe1,pipe2)
  if P!=None:
    frameCmd.extendTheBeam(pipe1,P)
    if both:
      frameCmd.extendTheBeam(pipe2,P)
Exemple #36
0
 def Activated (self):
   import pipeCmd, frameCmd
   from Part import Plane
   selex=FreeCADGui.Selection.getSelectionEx()
   for sx in selex:
     sxFaces=[f for f in frameCmd.faces([sx]) if type(f.Surface)==Plane]
     if len(sxFaces)>0:
       refFace=sxFaces[0]
       support=sx.Object
   FreeCAD.activeDocument().openTransaction('Raise-up the support')
   for b in frameCmd.beams():
     if pipeCmd.isPipe(b):
       pipeCmd.laydownTheTube(b,refFace,support)
       break
   FreeCAD.activeDocument().recompute()
   FreeCAD.activeDocument().commitTransaction()
Exemple #37
0
 def Activated (self):
   import pipeCmd, frameCmd
   from Part import Plane
   selex=FreeCADGui.Selection.getSelectionEx()
   for sx in selex:
     sxFaces=[f for f in frameCmd.faces([sx]) if type(f.Surface)==Plane]
     if len(sxFaces)>0:
       refFace=sxFaces[0]
       support=sx.Object
   FreeCAD.activeDocument().openTransaction('Raise-up the support')
   for b in frameCmd.beams():
     if pipeCmd.isPipe(b):
       pipeCmd.laydownTheTube(b,refFace,support)
       break
   FreeCAD.activeDocument().recompute()
   FreeCAD.activeDocument().commitTransaction()
Exemple #38
0
 def insert(self):
   tubes=[t for t in frameCmd.beams() if hasattr(t,'PSize')]
   if len(tubes)>0 and tubes[0].PSize in [prop['PSize'] for prop in self.pipeDictList]:
     for prop in self.pipeDictList:
       if prop['PSize']==tubes[0].PSize:
         d=prop
         break
   else:
     d=self.pipeDictList[self.sizeList.currentRow()]
   propList=[d['PSize'],d['FlangeType'],float(pq(d['D'])),float(pq(d['d'])),float(pq(d['df'])),float(pq(d['f'])),float(pq(d['t'])),int(d['n'])]
   FreeCAD.activeDocument().openTransaction('Insert flange')
   if len(frameCmd.edges())==0:
     vs=[v for sx in FreeCADGui.Selection.getSelectionEx() for so in sx.SubObjects for v in so.Vertexes]
     if len(vs)==0:
       self.lastFlange=pipeCmd.makeFlange(propList)
       self.lastFlange.PRating=self.PRating
       if self.combo.currentText()!='<none>':
         pipeCmd.moveToPyLi(self.lastFlange,self.combo.currentText())
     else:
       for v in vs:
         self.lastFlange=pipeCmd.makeFlange(propList,v.Point)
         self.lastFlange.PRating=self.PRating
         if self.combo.currentText()!='<none>':
           pipeCmd.moveToPyLi(self.lastFlange,self.combo.currentText())
   elif tubes:
     selex=FreeCADGui.Selection.getSelectionEx()
     for sx in selex:
       if hasattr(sx.Object,'PType') and sx.Object.PType=='Pipe' and frameCmd.edges([sx]):
         for edge in frameCmd.edges([sx]):
           if edge.curvatureAt(0)!=0:
             self.lastFlange=pipeCmd.makeFlange(propList,edge.centerOfCurvatureAt(0),sx.Object.Shape.Solids[0].CenterOfMass-edge.centerOfCurvatureAt(0))
             self.lastFlange.PRating=self.PRating
             if self.combo.currentText()!='<none>':
               pipeCmd.moveToPyLi(self.lastFlange,self.combo.currentText())
     FreeCAD.activeDocument().commitTransaction()
     FreeCAD.activeDocument().recompute()
     return
   else:
     for edge in frameCmd.edges():
       if edge.curvatureAt(0)!=0:
         self.lastFlange=pipeCmd.makeFlange(propList,edge.centerOfCurvatureAt(0),edge.tangentAt(0).cross(edge.normalAt(0)))
         self.lastFlange.PRating=self.PRating
         if self.combo.currentText()!='<none>':
           pipeCmd.moveToPyLi(self.lastFlange,self.combo.currentText())
   FreeCAD.activeDocument().commitTransaction()
   FreeCAD.activeDocument().recompute()
Exemple #39
0
 def breakPipe(self):
   p2nd=None
   FreeCAD.activeDocument().openTransaction('Break pipes')
   if self.edit1.text()[-1]=='%':
     pipes=[p for p in frameCmd.beams() if pipeCmd.isPipe(p)]
     for p in pipes:
       p2nd=pipeCmd.breakTheTubes(float(p.Height)*float(self.edit1.text().rstrip('%').strip())/100,pipes=[p],gap=float(self.edit2.text()))
       if p2nd and self.combo.currentText()!='<none>':
         for p in p2nd:
           pipeCmd.moveToPyLi(p,self.combo.currentText())
   else:
     p2nd=pipeCmd.breakTheTubes(float(self.edit1.text()),gap=float(self.edit2.text()))
     if p2nd and self.combo.currentText()!='<none>':
       for p in p2nd:
         pipeCmd.moveToPyLi(p,self.combo.currentText())
   FreeCAD.activeDocument().commitTransaction()
   FreeCAD.activeDocument().recompute()
Exemple #40
0
 def accept(self):
   if self.labTail:
     self.labTail.removeLabel()
     self.labTail=None
   self.L=frameCmd.getDistance()
   if self.form.edit1.text():
     length=float(self.form.edit1.text())
     FreeCAD.activeDocument().openTransaction('Stretch beam')
     for beam in frameCmd.beams():
       delta=float(beam.Height)-length
       frameCmd.stretchTheBeam(beam,length)
       if self.form.tail.isChecked():
         disp=frameCmd.beamAx(beam).multiply(delta)
         beam.Placement.move(disp)
       elif self.form.both.isChecked():
         disp=frameCmd.beamAx(beam).multiply(delta/2.0)
         beam.Placement.move(disp)
     FreeCAD.activeDocument().recompute()
     FreeCAD.activeDocument().commitTransaction()
Exemple #41
0
 def accept(self):  # stretch
     if self.labTail:
         self.labTail.removeLabel()
         self.labTail = None
     self.L = frameCmd.getDistance()
     if self.form.edit1.text():
         length = float(self.form.edit1.text())
         FreeCAD.activeDocument().openTransaction('Stretch beam')
         for beam in frameCmd.beams():
             delta = float(beam.Height) - length
             frameCmd.stretchTheBeam(beam, length)
             if self.form.tail.isChecked():
                 disp = frameCmd.beamAx(beam).multiply(delta)
                 beam.Placement.move(disp)
             elif self.form.both.isChecked():
                 disp = frameCmd.beamAx(beam).multiply(delta / 2.0)
                 beam.Placement.move(disp)
         FreeCAD.activeDocument().recompute()
         FreeCAD.activeDocument().commitTransaction()
Exemple #42
0
def reverseTheTube(objEx):
  '''
  reverseTheTube(objEx)
  Reverse the orientation of objEx spinning it 180 degrees around the x-axis
  of its shape.
  If an edge is selected, it's used as pivot.
  '''
  disp=None
  selectedEdges=[e for e in objEx.SubObjects if e.ShapeType=='Edge']
  if selectedEdges:
    for edge in frameCmd.edges([objEx]):
      if edge.curvatureAt(0):
        disp=edge.centerOfCurvatureAt(0)-objEx.Object.Placement.Base
        break
      elif frameCmd.beams([objEx.Object]):
        ax=frameCmd.beamAx(objEx.Object)
        disp=ax*((edge.CenterOfMass-objEx.Object.Placement.Base).dot(ax))
  rotateTheTubeAx(objEx.Object,FreeCAD.Vector(1,0,0),180)
  if disp:
    objEx.Object.Placement.move(disp*2)
Exemple #43
0
 def changeProfile(self):
   # find selected FB
   try:
     FB=findFB(baseName=FreeCADGui.Selection.getSelection()[0].Name)
     if not FB:
       FB=findFB(beamName=frameCmd.beams()[0].Name)
   except:
     FreeCAD.Console.PrintError('Nothing selected\n')
     return
   if FB and self.form.listSizes.selectedItems():
     if self.SType=='<by sketch>':
       profile=FreeCAD.ActiveDocument.getObjectsByLabel(self.form.listSizes.currentItem().text())[0]
     else:
       prop=self.sectDictList[self.form.listSizes.currentRow()]
       profile=newProfile(prop)
     name=FB.Profile.Name
     FB.Profile=profile
     FB.Proxy.redraw(FB)
     FreeCAD.ActiveDocument.removeObject(name)
     FreeCAD.ActiveDocument.recompute()
     FreeCAD.ActiveDocument.recompute()
   else:
     FreeCAD.Console.PrintError('No frameBranch or profile selected\n')
 def changeProfile(self):
     # find selected FB
     try:
         FB = findFB(baseName=FreeCADGui.Selection.getSelection()[0].Name)
         if not FB:
             FB = findFB(beamName=frameCmd.beams()[0].Name)
     except:
         FreeCAD.Console.PrintError('Nothing selected\n')
         return
     if FB and self.form.listSizes.selectedItems():
         if self.SType == '<by sketch>':
             profile = FreeCAD.ActiveDocument.getObjectsByLabel(
                 self.form.listSizes.currentItem().text())[0]
         else:
             prop = self.sectDictList[self.form.listSizes.currentRow()]
             profile = newProfile(prop)
         name = FB.Profile.Name
         FB.Profile = profile
         FB.Proxy.redraw(FB)
         FreeCAD.ActiveDocument.removeObject(name)
         FreeCAD.ActiveDocument.recompute()
         FreeCAD.ActiveDocument.recompute()
     else:
         FreeCAD.Console.PrintError('No frameBranch or profile selected\n')
Exemple #45
0
 def refresh(self):
   obj=findFB(frameCmd.beams()[0].Name)
   if not obj: obj=findFB(baseName=FreeCADGui.Selection.getSelection()[0])
   if obj: obj.Proxy.redraw(obj)
   FreeCAD.ActiveDocument.recompute()
   FreeCAD.ActiveDocument.recompute()
Exemple #46
0
 def writeTail(self):
   if frameCmd.beams():
     beam=frameCmd.beams()[0]
     from polarUtilsCmd import label3D
     self.labTail=label3D(pl=beam.Placement, text='____TAIL')
Exemple #47
0
 def selectAction(self):
     if len(frameCmd.beams()) > 0:
         self.beam = frameCmd.beams()[0]
         self.form.label.setText(self.beam.Label + ':' + self.beam.Profile)
         FreeCADGui.Selection.removeSelection(self.beam)
Exemple #48
0
 def selectAction(self):
   if len(frameCmd.beams())>0:
     self.beam=frameCmd.beams()[0]
     self.form.label.setText(self.beam.Label+':'+self.beam.Profile)
     FreeCADGui.Selection.removeSelection(self.beam)
Exemple #49
0
 def writeTail(self):
     if frameCmd.beams():
         beam = frameCmd.beams()[0]
         from polarUtilsCmd import label3D
         self.labTail = label3D(pl=beam.Placement,
                                text='____TAIL')  #, sizeFont=sc)
Exemple #50
0
 def removeBeams(self):
   for beam in frameCmd.beams():
     FB=findFB(beamName=beam.Name)
     if FB:
       i=FB.Beams.index(beam.Name)
       FB.Proxy.remove(i)