Пример #1
0
 def makeSingle(self):
   FreeCAD.activeDocument().openTransaction('Insert Single Struct')
   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)
   if fCmd.faces():
     Z=FreeCAD.Vector(0,0,1)
     for f in fCmd.faces():
       beam=makeStructure(profile)
       beam.Placement=FreeCAD.Placement(f.CenterOfMass,FreeCAD.Rotation(Z,f.normalAt(0,0)))
       if self.form.editLength.text(): beam.Height=float(self.form.editLength.text())
   elif fCmd.edges():
     for e in fCmd.edges():
       beam=makeStructure(profile)
       fCmd.placeTheBeam(beam,e)
       if self.form.editLength.text(): beam.Height=float(self.form.editLength.text())
   elif [v for sx in FreeCADGui.Selection.getSelectionEx() for so in sx.SubObjects for v in so.Vertexes]:
     vs=[v for sx in FreeCADGui.Selection.getSelectionEx() for so in sx.SubObjects for v in so.Vertexes]
     for v in vs:
       beam=makeStructure(profile)
       beam.Placement.Base=v.Point
   else:
     beam=makeStructure(profile)
     if self.form.editLength.text(): beam.Height=float(self.form.editLength.text())
   FreeCAD.ActiveDocument.recompute()
Пример #2
0
 def addBeams(self):
     # find selected FB
     try:
         FB = findFB(baseName=FreeCADGui.Selection.getSelection()[0].Name)
     except:
         return
     if FB:
         beamsList = FB.Beams
         for edge in frameCmd.edges():
             i = indexEdge(edge, FB.Base.Shape.Edges)
             beam = makeStructure(FB.Profile)
             beam.addProperty("App::PropertyFloat", "tailOffset",
                              "FrameBranch", "The extension of the tail")
             beam.addProperty("App::PropertyFloat", "headOffset",
                              "FrameBranch", "The extension of the head")
             beam.addProperty("App::PropertyFloat", "spin", "FrameBranch",
                              "The rotation of the section")
             beam.addExtension("Part::AttachExtensionPython", beam)
             beam.Support = [(FB.Base, 'Edge' + str(i + 1))]
             beam.MapMode = 'NormalToEdge'
             beam.MapReversed = True
             beamsList[i] = str(beam.Name)
         FB.Beams = beamsList
         FreeCAD.ActiveDocument.recompute()
         FreeCAD.ActiveDocument.recompute()
Пример #3
0
 def makeSingle(self):
   FreeCAD.activeDocument().openTransaction('Insert Single Struct')
   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)
   if frameCmd.faces():
     Z=FreeCAD.Vector(0,0,1)
     for f in frameCmd.faces():
       beam=makeStructure(profile)
       beam.Placement=FreeCAD.Placement(f.CenterOfMass,FreeCAD.Rotation(Z,f.normalAt(0,0)))
       if self.form.editLength.text(): beam.Height=float(self.form.editLength.text())
   else:
     for e in frameCmd.edges():
       beam=makeStructure(profile)
       frameCmd.placeTheBeam(beam,e)
       if self.form.editLength.text(): beam.Height=float(self.form.editLength.text())
   FreeCAD.ActiveDocument.recompute()
Пример #4
0
 def insert(self):
   from pipeCmd import moveToPyLi
   if self.combo.currentText()=='<new>':
     name=self.edit1.text()
     if not name: name='Telaio'
     a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
     FrameLine(a)
     a.ViewObject.Proxy=0
     self.combo.addItem(a.Label)
     self.combo.setCurrentIndex(self.combo.count()-1)
     if self.sectList.selectedItems():
       self.getProfile()
   elif self.sectList.selectedItems():
     prof= FreeCAD.ActiveDocument.getObjectsByLabel(self.sectList.selectedItems()[0].text())[0]
     for e in frameCmd.edges():
       if self.cb1.isChecked():
         s=makeStructure(FreeCAD.ActiveDocument.copyObject(prof))
       else:
         s=makeStructure(prof)
       frameCmd.placeTheBeam(s,e)
       moveToPyLi(s,self.current.Name)
     FreeCAD.ActiveDocument.recompute()
Пример #5
0
 def insert(self):
   from pCmd import moveToPyLi
   if self.combo.currentText()=='<new>':
     name=self.edit1.text()
     if not name: name='Telaio'
     a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
     FrameLine(a)
     a.ViewObject.Proxy=0
     self.combo.addItem(a.Label)
     self.combo.setCurrentIndex(self.combo.count()-1)
     if self.sectList.selectedItems():
       self.getProfile()
   elif self.sectList.selectedItems():
     prof= FreeCAD.ActiveDocument.getObjectsByLabel(self.sectList.selectedItems()[0].text())[0]
     for e in fCmd.edges():
       if self.cb1.isChecked():
         s=makeStructure(FreeCAD.ActiveDocument.copyObject(prof))
       else:
         s=makeStructure(prof)
       fCmd.placeTheBeam(s,e)
       moveToPyLi(s,self.current.Name)
     FreeCAD.ActiveDocument.recompute()
Пример #6
0
 def makeSingle(self):
     FreeCAD.activeDocument().openTransaction('Insert Single Struct')
     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)
     if frameCmd.faces():
         Z = FreeCAD.Vector(0, 0, 1)
         for f in frameCmd.faces():
             beam = makeStructure(profile)
             beam.Placement = FreeCAD.Placement(
                 f.CenterOfMass, FreeCAD.Rotation(Z, f.normalAt(0, 0)))
             if self.form.editLength.text():
                 beam.Height = float(self.form.editLength.text())
     else:
         for e in frameCmd.edges():
             beam = makeStructure(profile)
             frameCmd.placeTheBeam(beam, e)
             if self.form.editLength.text():
                 beam.Height = float(self.form.editLength.text())
     FreeCAD.ActiveDocument.recompute()
Пример #7
0
 def insert(self):
     from frameCmd import makeFrameLine, edges, placeTheBeam
     from pipeCmd import moveToPyLi
     if self.combo.currentText() == '<new>':
         n = self.edit1.text()
         if n:
             a = makeFrameLine(name=n)
         else:
             a = makeFrameLine()
         self.combo.addItem(a.Label)
         self.combo.setCurrentIndex(self.combo.count() - 1)
         if self.sectList.selectedItems():
             self.getProfile()
     elif self.sectList.selectedItems():
         prof = FreeCAD.ActiveDocument.getObjectsByLabel(
             self.sectList.selectedItems()[0].text())[0]
         for e in edges():
             if self.cb1.isChecked():
                 s = makeStructure(FreeCAD.ActiveDocument.copyObject(prof))
             else:
                 s = makeStructure(prof)
             placeTheBeam(s, e)
             moveToPyLi(s, self.current.Name)
         FreeCAD.ActiveDocument.recompute()
Пример #8
0
 def redraw(self, obj):
   # clear all
   for o in obj.Beams: FreeCAD.ActiveDocument.removeObject(o)
   # create new beams
   i=0
   beamsList=[]
   for e in obj.Base.Shape.Edges:
     beam=makeStructure(obj.Profile)
     beam.addProperty("App::PropertyFloat","tailOffset","FrameBranch","The extension of the tail")
     beam.addProperty("App::PropertyFloat","headOffset","FrameBranch","The extension of the head")
     beam.addProperty("App::PropertyFloat","spin","FrameBranch","The rotation of the section")
     beam.addExtension("Part::AttachExtensionPython",beam)
     beam.Support=[(obj.Base,'Edge'+str(i+1))]
     beam.MapMode='NormalToEdge'
     beam.MapReversed=True
     beamsList.append(str(beam.Name))
     i+=1
   obj.Beams=beamsList
Пример #9
0
 def update(self,fp,copyProfile=True):
   if hasattr(fp.Base,'Shape'):
     edges=fp.Base.Shape.Edges
     if not edges:
       FreeCAD.Console.PrintError('Base has not valid edges\n')
       return
   group=FreeCAD.activeDocument().getObjectsByLabel(fp.Group)[0]
   if fp.Profile:
     FreeCAD.activeDocument().openTransaction('Update frameLine')
     for e in edges:
       if copyProfile:
         p=FreeCAD.activeDocument().copyObject(fp.Profile,True)
       else:
         p=fp.Profile
       beam=makeStructure(p)
       frameCmd.placeTheBeam(beam,e)
       pipeCmd.moveToPyLi(beam,fp.Name)
     FreeCAD.activeDocument().commitTransaction()
   FreeCAD.activeDocument().recompute()
Пример #10
0
 def redraw(self, obj):
   # clear all
   for o in obj.Beams: FreeCAD.ActiveDocument.removeObject(o)
   # create new beams
   i=0
   beamsList=[]
   for e in obj.Base.Shape.Edges:
     if e.curvatureAt(0)==0:
       beam=makeStructure(obj.Profile)
       beam.addProperty("App::PropertyFloat","tailOffset","FrameBranch","The extension of the tail")
       beam.addProperty("App::PropertyFloat","headOffset","FrameBranch","The extension of the head")
       beam.addProperty("App::PropertyFloat","spin","FrameBranch","The rotation of the section")
       beam.addExtension("Part::AttachExtensionPython",beam)
       beam.Support=[(obj.Base,'Edge'+str(i+1))]
       beam.MapMode='NormalToEdge'
       beam.MapReversed=True
       beamsList.append(str(beam.Name))
       i+=1
   obj.Beams=beamsList
Пример #11
0
 def update(self,fp,copyProfile=True):
   if hasattr(fp.Base,'Shape'):
     edges=fp.Base.Shape.Edges
     if not edges:
       FreeCAD.Console.PrintError('Base has not valid edges\n')
       return
   group=FreeCAD.activeDocument().getObjectsByLabel(fp.Group)[0]
   if fp.Profile:
     FreeCAD.activeDocument().openTransaction('Update frameLine')
     for e in edges:
       if copyProfile:
         p=FreeCAD.activeDocument().copyObject(fp.Profile,True)
       else:
         p=fp.Profile
       beam=makeStructure(p)
       fCmd.placeTheBeam(beam,e)
       pCmd.moveToPyLi(beam,fp.Name)
     FreeCAD.activeDocument().commitTransaction()
   FreeCAD.activeDocument().recompute()
Пример #12
0
 def addBeams(self):
   # find selected FB
   try:
     FB=findFB(baseName=FreeCADGui.Selection.getSelection()[0].Name)
   except:
     return
   if FB:
     beamsList=FB.Beams
     for edge in frameCmd.edges():
       i=indexEdge(edge,FB.Base.Shape.Edges)
       beam=makeStructure(FB.Profile)
       beam.addProperty("App::PropertyFloat","tailOffset","FrameBranch","The extension of the tail")
       beam.addProperty("App::PropertyFloat","headOffset","FrameBranch","The extension of the head")
       beam.addProperty("App::PropertyFloat","spin","FrameBranch","The rotation of the section")
       beam.addExtension("Part::AttachExtensionPython",beam)
       beam.Support=[(FB.Base,'Edge'+str(i+1))]
       beam.MapMode='NormalToEdge'
       beam.MapReversed=True
       beamsList[i]=str(beam.Name)
     FB.Beams=beamsList
     FreeCAD.ActiveDocument.recompute()
     FreeCAD.ActiveDocument.recompute()