Code: Select all
#-*- coding: utf-8 -*-
#
# Dessin pignon GT2
#
import Draft, Part
import sys
import math
import Part
import sys
import FreeCAD, FreeCADGui
import Sketcher, PartDesign
import ProfileLib.RegularPolygon
from FreeCAD import Base
from PySide import QtCore, QtGui
def proceed():
# Données nécessaires au dessin
Type = t0.currentText()
# App.Console.PrintMessage('Type = ' + str(Type)+"\n")
nombre_de_dents = float(s1.text())
# App.Console.PrintMessage('nb dents = ' + str(nombre_de_dents)+"\n")
pas = 2
# App.Console.PrintMessage('Pas = ' + str(pas)+"\n")
PLD = 0.255
# App.Console.PrintMessage('PLD = ' + str(PLD)+"\n")
h = 0.75
# App.Console.PrintMessage('h = ' + str(h)+"\n")
circonference = nombre_de_dents * pas
# App.Console.PrintMessage('circonference = ' + str(circonference)+"\n")
diametre_primitif = circonference / math.pi
# App.Console.PrintMessage('diametre_primitif = ' + str(diametre_primitif)+"\n")
diametre_poulie = diametre_primitif - (PLD * 2)
# App.Console.PrintMessage('diametre_poulie = ' + str(diametre_poulie)+"\n")
rayon_poulie = diametre_poulie / 2
# App.Console.PrintMessage('rayon_poulie = ' + str(rayon_poulie)+"\n")
largeur_poulie = float(s2.text())
# App.Console.PrintMessage('largeur_poulie = ' + str(largeur_poulie)+"\n")
rayon_R1 = 0.15
# App.Console.PrintMessage('rayon_R1 = ' + str(rayon_R1)+"\n")
positionX = rayon_poulie
# App.Console.PrintMessage('positionX = ' + str(positionX)+"\n")
rayon_R2 = 1
# App.Console.PrintMessage('rayon_R2 = ' + str(rayon_R2)+"\n")
positionX_R2 = 0.4
# App.Console.PrintMessage('positionX_R2 = ' + str(positionX_R2)+"\n")
rayon_R3 = 0.555
# App.Console.PrintMessage('rayon_R3 = ' + str(rayon_R3)+"\n")
positionX_R3 = rayon_poulie - (h - rayon_R3)
# App.Console.PrintMessage('positionX_R3 = ' + str(positionX_R3)+"\n")
###
# ici on insére le teste de présence nouveau fichier part body sketch
###
###
# ici on insére le dessin
###
close()
def close():
dialog.hide()
dialog.close()
print('Terminé')
def __init__():
# Initialisation
dialog = None
s1 = None
dialog = QtGui.QDialog()
dialog.resize(180,160) # Dimentionner la boite de dialogue
dialog.setWindowTitle("Poulie GT2") # Titre de la fenetre
la = QtGui.QVBoxLayout(dialog)
t0 = QtGui.QLabel("Type de poulie") # Affichage Label
la.addWidget(t0)
t0 = QtGui.QComboBox() # Affichage ComboBox
la.addWidget(t0)
t0.addItems(["GT2", "GT3", "GT5"])
t2 = QtGui.QLabel("Nombre de Dents") # Affichage Label
la.addWidget(t2)
s1 = QtGui.QLineEdit() # Affichage LineEdit
s1.setText("16.0")
s1.setFixedWidth(100)
la.addWidget(s1)
t3 = QtGui.QLabel("Largeur Poulie") # Affichage Label
la.addWidget(t3)
s2 = QtGui.QLineEdit() # Affichage LineEdit
s2.setText("8.0")
s2.setFixedWidth(100)
la.addWidget(s2)
# Gestion boutons OK / Cancel
okbox = QtGui.QDialogButtonBox(dialog)
okbox.setOrientation(QtCore.Qt.Horizontal)
okbox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
la.addWidget(okbox)
QtCore.QObject.connect(okbox, QtCore.SIGNAL("accepted()"), proceed)
QtCore.QObject.connect(okbox, QtCore.SIGNAL("rejected()"), close)
QtCore.QMetaObject.connectSlotsByName(dialog)
dialog.show()
dialog.exec_()