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()
def accept(self): if self.beam!=None and len(fCmd.edges())>0: FreeCAD.activeDocument().openTransaction('Fill frame') if self.form.radio1.isChecked(): fCmd.placeTheBeam(self.beam,fCmd.edges()[0]) else: for edge in fCmd.edges(): struct=FreeCAD.activeDocument().copyObject(self.beam,True) fCmd.placeTheBeam(struct,edge) FreeCAD.activeDocument().recompute() FreeCAD.ActiveDocument.recompute() FreeCAD.activeDocument().commitTransaction()
def addSelection(self, doc, obj, sub, pnt): if self.beam == None and FreeCAD.getDocument(doc).getObject( obj).TypeId == 'Part::FeaturePython': self.beam = FreeCAD.getDocument(doc).getObject(obj) FreeCAD.Console.PrintMessage('Beam type selected.\n') else: subObject = FreeCAD.getDocument(doc).getObject( obj).Shape.getElement(sub) if subObject.ShapeType == "Edge" and self.beam != None: fCmd.placeTheBeam( FreeCAD.activeDocument().copyObject(self.beam, True), subObject)
def addSelection(self, doc, obj, sub, pnt): selex = FreeCADGui.Selection.getSelectionEx() if self.beam == None and hasattr(selex[len(selex) - 1].Object, 'Height'): self.beam = selex[len(selex) - 1].Object FreeCAD.Console.PrintMessage('Beam selected\n') elif self.edge == None and selex[len(selex) - 1].SubObjects[0].ShapeType == 'Edge': self.edge = selex[len(selex) - 1].SubObjects[0] FreeCAD.Console.PrintMessage('Edge selected\n') if self.edge != None and self.beam != None: fCmd.placeTheBeam(self.beam, self.edge) FreeCAD.Console.PrintMessage('Beam placed.\n') FreeCAD.Console.PrintWarning( 'Select another beam and another edge.\n[ESC] to exit.\n') self.beam = self.edge = None FreeCAD.activeDocument().recompute()
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()
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()