Beispiel #1
0
 def redraw(self):
     for l in self.labNodes + self.labEl:
         l.removeLabel()
     if self.form.comboBox.currentText():
         frame = FreeCAD.ActiveDocument.getObjectsByLabel(
             self.form.comboBox.currentText())[0]
         sk = frame.Base
         A = frame.Profile.Shape.Area
         I = frame.Profile.Shape.MatrixOfInertia.multiply(X).dot(X)
         ss = SystemElements()
         i = 1
         for l in sk.Geometry:
             sp = [i * 1e-3 for i in list(l.StartPoint)[:2]]
             ep = [i * 1e-3 for i in list(l.EndPoint)[:2]]
             ss.add_element([sp, ep], EA=E * A * 1e-3, EI=E * I * 1e-9)
             p2 = FreeCAD.Placement()
             p2.Base = sk.Placement.multVec((l.StartPoint + l.EndPoint) / 2)
             self.labNodes.append(
                 label3D(pl=p2, color=(0, 0.8, 0),
                         text='____beam' + str(i)))
             i += 1
         nodes = ss.nodes_range('both')
         coords = [
             FreeCAD.Vector(n[0] * 1000, n[1] * 1000, 0) for n in nodes
         ]
         globalCoords = [sk.Placement.multVec(c) for c in coords]
         i = 1
         for gc in globalCoords:
             self.labNodes.append(
                 label3D(pl=FreeCAD.Placement(gc, FreeCAD.Rotation()),
                         text='____node' + str(i)))
             i += 1
         self.form.editE.setText(str(E))
         self.form.editA.setText(str(A))
         self.form.editI.setText(str(I))
         n = len(sk.Geometry)
         self.form.tableDistrib.setRowCount(n)
         self.combotypes.clear()
         for i in list(range(n)):
             item = QTableWidgetItem('%.1f m' %
                                     (sk.Geometry[i].length() / 1000))
             self.form.tableDistrib.setItem(i, 0, item)
             self.combotypes.append(QComboBox())
             self.combotypes[-1].addItems(['beam', 'brace'])
             self.form.tableDistrib.setCellWidget(i, 1, self.combotypes[-1])
         #self.form. tableDistrib.setItem(0,1,QTableWidgetItem('1000')) #for test
         self.form.table_2.setRowCount(ss.id_last_node)
         self.form.tableConc.setRowCount(ss.id_last_node)
         self.combos.clear()
         for i in list(range(ss.id_last_node)):
             self.form.table_2.setItem(
                 i, 0,
                 QTableWidgetItem('%.2f, %.2f' % ss.nodes_range('both')[i]))
             self.combos.append(QComboBox())
             self.combos[-1].addItems(['-', 'fix', 'hinge', 'roll'])
             self.form.table_2.setCellWidget(i, 1, self.combos[-1])
             self.form.tableConc.setItem(
                 i, 0,
                 QTableWidgetItem('%.2f, %.2f' % ss.nodes_range('both')[i]))
Beispiel #2
0
def redraw():
    frame = FreeCAD.ActiveDocument.getObjectsByLabel(
        ui.comboBox.currentText())[0]
    print(frame.Label)
    sk = frame.Base
    print('\tBase: ' + sk.Label)
    A = frame.Profile.Shape.Area * 1e-6
    I = frame.Profile.Shape.MatrixOfInertia.multiply(X).dot(X) * 1e-12
    ss = SystemElements()
    for l in sk.Geometry:
        sp = [i * 1e-3 for i in list(l.StartPoint)[:2]]
        ep = [i * 1e-3 for i in list(l.EndPoint)[:2]]
        ss.add_element([sp, ep], EA=E * A, EI=E * I)
    print('\tNodes: %i\n\tElements: %i\n\n' %
          (ss.id_last_node, ss.id_last_element))
    ss.show_structure()
    ui.editE.setText(str(E))
    ui.editA.setText(str(A))
    ui.editI.setText(str(I))
    n = len(sk.Geometry)
    ui.table.setRowCount(n)
    for i in list(range(n)):
        item = QtGui.QTableWidgetItem('%.1f m' %
                                      (sk.Geometry[i].length() / 1000))
        ui.table.setItem(i, 0, item)
    ui.table.setItem(3, 1, QtGui.QTableWidgetItem('-2000'))  #for test
    ui.table.setItem(4, 1, QtGui.QTableWidgetItem('-1000'))  #for test
    ui.table_2.setRowCount(ss.id_last_node)
    for i in list(range(ss.id_last_node)):
        ui.table_2.setItem(
            i, 0,
            QtGui.QTableWidgetItem('%.2f, %.2f' % ss.nodes_range('both')[i]))
    ui.table_2.setItem(0, 1, QtGui.QTableWidgetItem('fix'))  #for test
    ui.table_2.setItem(3, 1, QtGui.QTableWidgetItem('roll'))  #for test
    ui.table_2.setItem(5, 1, QtGui.QTableWidgetItem('hinge'))  #for test