Macro Airfoil Import & Scale
Beschreibung |
---|
Verfolgen Sie den Umfang eines Airfoil aus einer DAT-Datei. Versionsmakro : 1.5 , 2.0 and 2.1 Datum der letzten Änderung : 2014-10-02 Autor: quick61 |
Autor |
quick61 |
Herunterladen |
None |
Links |
Makros Rezepte Wie installiere ich Makros So passen Sie Symbolleisten an |
Macro-Version |
1.5 , 2.0 and 2.1 |
Datum der letzten Änderung |
2014-10-02 |
FreeCAD-Version(s) |
None |
Standardverknüpfung |
None |
Siehe auch |
None |
Beschreibung
Wenn dieses Makro ausgeführt wird, wird es dem Benutzer zunächst mit einem Dateibrowser zur Verfügung gestellt, um eine .dat-Profildatei zu finden und auszuwählen. Nach der Auswahl wird eine Akkordlänge eingegeben und beim Drücken der OK-Taste wird ein ordnungsgemäß skaliertes Strömungsprofil erzeugt. Hier gibt es zwei Versionen. Version 1.5 sollte auf FreeCAD-Versionen funktionieren, 0,13 stabil sowie alle 0,14-Versionen. Version 2 sollte nur mit FreeCAD-Versionen größer oder gleich 0,14 3077 verwendet werden und funktioniert am besten mit Versionen, die mit OCE/OCC-Versionen 6.7 oder höher erstellt wurden.
Siehe auch Common Airfoil Data Import
Wie benutzt man - Version 1.5
Wähle die Datei
Beim Ausführen des Makros wird dem Benutzer zunächst ein Dateibrowser angezeigt, in dem Sie die gewünschte DAT-Datei auswählen können. Navigieren Sie zu dem Speicherort der Airfoil-Datei, wählen Sie sie aus und drücken Sie Öffnen.
Geben Sie die Akkordlänge ein
Nachdem die Airfoil-Datei ausgewählt wurde, erscheint ein neuer Dialog, in dem Sie nach einer Akkordlänge gefragt werden. Jede Länge kann in Millimetern eingegeben werden. Nachdem Sie die gewünschte Länge eingegeben haben, erzeugt das Makro einen Zugdraht (DWire), der den Punkten entspricht, die in der zuvor ausgewählten .dat-Profildatei auf der für die Akkordlänge eingegebenen Skala angegeben sind.
The Airfoil, properly scaled, should now be ready for use in your project.
How To Use - Version 2
File selection is the same as version 1.5. With version 2 you now have the choice to either have the resulting airfoil made with a Draft Wire (DWire) or a Basic Spline (BSpline). As with version 1.5, you enter the desired chord length. Additionally you can now select which type of foil you want. Simply click on the BSpline radio button or leave as is for for the default DWire.
The Macros
Version 1.5
Macro_Airfoil_Import_&_Scale.FCMacro
# # # #
#
# AIRFOIL IMPORT & SCALE v1.5
#
# Imports and scales an Airfoil in the form of a Draft Wire (DWire)
#
# # # #
from PySide import QtCore, QtGui
from PySide.QtGui import QLineEdit
import FreeCAD, FreeCADGui, Draft
import importAirfoilDAT
# Select .dat airfoil data file to be imported
filename = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(),'Open An Airfoil File','*.dat')
class p():
def proceed(self):
try:
# This produces a scaled Airfoil with a DWire
scalefactor=float(self.s1.text())
f1=str(filename)
importAirfoilDAT.insert(f1,"Unnamed")
Draft.scale(App.ActiveDocument.ActiveObject,delta=App.Vector(scalefactor,scalefactor,scalefactor),center=App.Vector(0,0,0),legacy=True)
except:
FreeCAD.Console.PrintError("Error, not a valid .dat file\n")
self.close()
def close(self):
self.dialog.hide()
def __init__(self):
self.dialog = None
self.s1 = None
# Make dialog box and get the scale size
self.dialog = QtGui.QDialog()
self.dialog.resize(350,100)
self.dialog.setWindowTitle("Airfoil Import & Scale")
la = QtGui.QVBoxLayout(self.dialog)
t1 = QtGui.QLabel("Chord Length")
la.addWidget(t1)
self.s1 = QtGui.QLineEdit()
la.addWidget(self.s1)
# Add OK / Cancel buttons
#ori okbox = QtGui.QDialogButtonBox(self.dialog)
#ori okbox.setOrientation(QtCore.Qt.Horizontal)
#ori okbox.setStandardButtons(QtGui.QDialogButtonBox.Cancel -PIPE- QtGui.QDialogButtonBox.Ok)
# modify original code for install with addon-install cause -PIPE- 05-12-2016 FC 0.16
okbox = QtGui.QDialogButtonBox(self.dialog)
okbox.setOrientation(QtCore.Qt.Horizontal)
okbox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
cancelbox = QtGui.QDialogButtonBox(self.dialog)
cancelbox.setOrientation(QtCore.Qt.Horizontal)
cancelbox.setStandardButtons(QtGui.QDialogButtonBox.Cancel)
cancelbox.move(0,62)
la.addWidget(okbox)
QtCore.QObject.connect(okbox, QtCore.SIGNAL("accepted()"), self.proceed)
QtCore.QObject.connect(cancelbox, QtCore.SIGNAL("rejected()"), self.close)
QtCore.QMetaObject.connectSlotsByName(self.dialog)
self.dialog.show()
self.dialog.exec_()
p()
Editing The Default Selection
If you primarily wish to have your imported and scaled airfoils made with BSplines rather than DWires, the Marco may be edited to default to the Bspline. This is done by editing the line -
##exampleCode## self.radio1.setChecked(True)
- and changing it to -
##exampleCode## self.radio2.setChecked(True)
A note on this is included within the text of the macro.
Version 2
# # # # # # AIRFOIL IMPORT & SCALE v2. # # Imports and scales an Airfoil in the form of a Draft Wire (DWire) or Basic Spline (BSpline) # # For FreeCAD Versions = or > 0.14 Revision 3077 # # Works best with OCC/OCE = or > 6.7 # # # # # from PySide import QtCore, QtGui from PySide.QtGui import QLineEdit, QRadioButton import FreeCAD, FreeCADGui, Draft import importAirfoilDAT # Select .dat airfoil data file to be imported filename = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(),'Open An Airfoil File','*.dat') class p(): def proceed(self): if self.radio1.isChecked(): try: # This produces a scaled Airfoil with a DWire scalefactor=float(self.s1.text()) f1=str(filename) importAirfoilDAT.insert(f1,"Unnamed") Draft.scale(App.ActiveDocument.ActiveObject,delta=App.Vector(scalefactor,scalefactor,scalefactor),center=App.Vector(0,0,0),legacy=True) except: FreeCAD.Console.PrintError("Error, not a valid .dat file\n") self.close() if self.radio2.isChecked(): try: # This produces a scaled Airfoil with a BSpline scalefactor=float(self.s1.text()) f1=str(filename) importAirfoilDAT.insert(f1,"Unnamed") points = FreeCAD.ActiveDocument.ActiveObject.Points Draft.makeBSpline(points, closed=True) Draft.scale(App.ActiveDocument.ActiveObject,delta=App.Vector(scalefactor,scalefactor,scalefactor),center=App.Vector(0,0,0),legacy=True) App.getDocument("Unnamed").removeObject("DWire") except: FreeCAD.Console.PrintError("Error, not a valid .dat file\n") self.close() def close(self): self.dialog.hide() def __init__(self): self.dialog = None self.s1 = None # Make dialog box and get the scale size self.dialog = QtGui.QDialog() self.dialog.resize(350,100) self.dialog.setWindowTitle("Airfoil Import & Scale") la = QtGui.QVBoxLayout(self.dialog) t1 = QtGui.QLabel("Chord Length") la.addWidget(t1) self.s1 = QtGui.QLineEdit() la.addWidget(self.s1) # Add radio buttons to select between DWire and BSpline self.radio1 = QRadioButton("Make DWire") self.radio2 = QRadioButton("Make BSpline") # set default to DWire & make radio buttons - Change self.radio1.setChecked(True) to # self.radio2.setChecked(True) to set BSpline as default self.radio1.setChecked(True) la.addWidget(self.radio1) la.addWidget(self.radio2) # Add OK / Cancel buttons okbox = QtGui.QDialogButtonBox(self.dialog) okbox.setOrientation(QtCore.Qt.Horizontal) okbox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) la.addWidget(okbox) QtCore.QObject.connect(okbox, QtCore.SIGNAL("accepted()"), self.proceed) QtCore.QObject.connect(okbox, QtCore.SIGNAL("rejected()"), self.close) QtCore.QMetaObject.connectSlotsByName(self.dialog) self.dialog.show() self.dialog.exec_() p()
Version 2.1
Updated by mangtronix to use PySide instead of PyQt (used in older versions of FreeCAD)
# # # # # # AIRFOIL IMPORT & SCALE v2.1 # # Imports and scales an Airfoil in the form of a Draft Wire (DWire) or Basic Spline (BSpline) # # For FreeCAD Versions = or > 0.14 Revision 3703 # # Works best with OCC/OCE = or > 6.7 # # # # # from PySide import QtCore, QtGui from PySide.QtGui import QLineEdit, QRadioButton import FreeCAD, FreeCADGui, Draft import importAirfoilDAT # Select .dat airfoil data file to be imported # PySide returns a tuple (filename, filter) instead of just a string like in PyQt filename, filefilter = QtGui.QFileDialog.getOpenFileName(QtGui.qApp.activeWindow(),'Open An Airfoil File','*.dat') class p(): def proceed(self): global filename if self.radio1.isChecked(): #if True: try: # This produces a scaled Airfoil with a DWire scalefactor=float(self.s1.text()) f1=str(filename) importAirfoilDAT.insert(f1,"Unnamed") Draft.scale(App.ActiveDocument.ActiveObject,delta=App.Vector(scalefactor,scalefactor,scalefactor),center=App.Vector(0,0,0),legacy=True) except Exception, e: FreeCAD.Console.PrintError("Error, not a valid .dat file\n") self.close() if self.radio2.isChecked(): try: # This produces a scaled Airfoil with a BSpline scalefactor=float(self.s1.text()) f1=str(filename) importAirfoilDAT.insert(f1,"Unnamed") points = FreeCAD.ActiveDocument.ActiveObject.Points Draft.makeBSpline(points, closed=True) Draft.scale(App.ActiveDocument.ActiveObject,delta=App.Vector(scalefactor,scalefactor,scalefactor),center=App.Vector(0,0,0),legacy=True) App.getDocument("Unnamed").removeObject("DWire") except: FreeCAD.Console.PrintError("Error, not a valid .dat file\n") self.close() def close(self): self.dialog.hide() def __init__(self): self.dialog = None self.s1 = None # Make dialog box and get the scale size self.dialog = QtGui.QDialog() self.dialog.resize(350,100) self.dialog.setWindowTitle("Airfoil Import & Scale") la = QtGui.QVBoxLayout(self.dialog) t1 = QtGui.QLabel("Chord Length") la.addWidget(t1) self.s1 = QtGui.QLineEdit() la.addWidget(self.s1) # Add radio buttons to select between DWire and BSpline self.radio1 = QRadioButton("Make DWire") self.radio2 = QRadioButton("Make BSpline") # set default to DWire & make radio buttons - Change self.radio1.setChecked(True) to # self.radio2.setChecked(True) to set BSpline as default self.radio1.setChecked(True) la.addWidget(self.radio1) la.addWidget(self.radio2) # Add OK / Cancel buttons okbox = QtGui.QDialogButtonBox(self.dialog) okbox.setOrientation(QtCore.Qt.Horizontal) okbox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) la.addWidget(okbox) QtCore.QObject.connect(okbox, QtCore.SIGNAL("accepted()"), self.proceed) QtCore.QObject.connect(okbox, QtCore.SIGNAL("rejected()"), self.close) QtCore.QMetaObject.connectSlotsByName(self.dialog) self.dialog.show() self.dialog.exec_() p()
Link
Discussion on Forum
UIUC Applied Aerodynamics Group Departement of Aerospace Engineering