FreeCAD-Doc/localwiki/Macro_Airfoil_Import_%26_Scale-it.html
2018-07-19 18:47:02 -05:00

423 lines
19 KiB
HTML

<html><head><title>Macro Airfoil Import %26 Scale/it</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Macro Airfoil Import %26 Scale/it</h1></div>
<div id="mw-content-text" lang="it" dir="ltr" class="mw-content-ltr"><hr/><div class="mw-parser-output"><table class="fcinfobox wikitable ct" width="100%" style="float: right; width: 230px; margin-left: 10px;">
<tr>
<td class="ctTitle">
<h3><span class="mw-headline" id="Airfoil_Import_.26_Scale"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Text-x-python.png" class="image"><img alt="Text-x-python.png" src="32px-Text-x-python.png" width="32" height="32" srcset="/wiki/images/2/2c/Text-x-python.png 1.5x" /></a> Airfoil Import &amp; Scale</span></h3>
</td></tr>
<tr>
<th class="ctOdd">Descrizione
</th></tr>
<tr>
<td class="ctEven left">Traccia il perimetro di un profilo alare da un file .dat.
</td></tr>
<tr>
<th class="ctOdd">Autore
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Quick61" title="User:Quick61">quick61</a>
</td></tr>
<tr>
<th class="ctOdd">Link
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/it" title="Macros recipes/it">Esempi di macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/it" title="How to install macros/it">Come installare le Macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/it" title="Customize Toolbars/it">Personalizzare la barra degli strumenti</a>
</td></tr>
<tr>
<th class="ctOdd">Versione
</th></tr>
<tr>
<td class="ctEven macro-version">1.5 , 2.0 and 2.1
</td></tr>
<tr>
<th class="ctOdd">Data ultima modifica
</th></tr>
<tr>
<td class="ctEven macro-date">2014-10-02
</td></tr>
<tr>
<th class="ctOdd">
</th></tr>
<tr>
<td class="ctToc"><br /><div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1"><a href="#Airfoil_Import_.26_Scale"><span class="tocnumber">1</span> <span class="toctext">Airfoil Import &amp; Scale</span></a></li>
<li class="toclevel-1 tocsection-1"><a href="#Come_utilizzare_la_Versione_1.5"><span class="tocnumber">2</span> <span class="toctext">Come utilizzare la Versione 1.5</span></a>
<ul>
<li class="toclevel-2 tocsection-2"><a href="#Selezionare_il_file."><span class="tocnumber">2.1</span> <span class="toctext">Selezionare il file.</span></a></li>
<li class="toclevel-2 tocsection-3"><a href="#Immettere_la_lunghezza_della_corda"><span class="tocnumber">2.2</span> <span class="toctext">Immettere la lunghezza della corda</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-4"><a href="#Come_utilizzare_la_Versione_2"><span class="tocnumber">3</span> <span class="toctext">Come utilizzare la Versione 2</span></a>
<ul>
<li class="toclevel-2 tocsection-5"><a href="#Modificare_la_selezione_predefinita"><span class="tocnumber">3.1</span> <span class="toctext">Modificare la selezione predefinita</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-6"><a href="#La_Macro"><span class="tocnumber">4</span> <span class="toctext">La Macro</span></a>
<ul>
<li class="toclevel-2 tocsection-7"><a href="#Versione_1.5"><span class="tocnumber">4.1</span> <span class="toctext">Versione 1.5</span></a></li>
<li class="toclevel-2 tocsection-8"><a href="#Versione_2"><span class="tocnumber">4.2</span> <span class="toctext">Versione 2</span></a></li>
<li class="toclevel-2 tocsection-9"><a href="#Version_2.1"><span class="tocnumber">4.3</span> <span class="toctext">Version 2.1</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-10"><a href="#Link"><span class="tocnumber">5</span> <span class="toctext">Link</span></a></li>
</ul>
</div>
</td></tr>
</table>
<p><br />
</p><p><br />
Quando viene eseguita, questa macro apre una cartella di file per individuare e selezionare un file testo di profili alari <b>.dat</b>. Selezionare il file, immettere la lunghezza di corda e poi premere il pulsante <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">OK</span>. Viene prodotto un profilo alare correttamente
scalato. <br />
Sono fornite due versioni. La versione 1.5 dovrebbe funzionare con FreeCAD v. 0,13 stabile e con tutte le versioni 0,14. La versione 2 deve essere utilizzata solo con la versione 0,14 3077 o successive e funzionerà meglio con le versioni costruite con versioni OCE/OCC 6.7 o superiore.
</p><p>Vedere anche la pagina <a href="https://www.freecadweb.org/wiki/index.php?title=Common_Airfoil_Data_Import/it" title="Common Airfoil Data Import/it">Importare Dati Airfoil </a>
</p><p><br />
<a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro_Airfoil_Import_%26_Scale_00.png" class="image"><img alt="Macro Airfoil Import &amp; Scale 00.png" src="480px-Macro_Airfoil_Import_%26_Scale_00.png" width="480" height="423" srcset="/wiki/images/4/43/Macro_Airfoil_Import_%26_Scale_00.png 1.5x" /></a>
</p>
<div style="clear:both"></div>
<p><br />
</p>
<h2><span class="mw-headline" id="Come_utilizzare_la_Versione_1.5">Come utilizzare la Versione 1.5</span></h2>
<h3><span class="mw-headline" id="Selezionare_il_file.">Selezionare il file.</span></h3>
<p>La Macro apre un eploratore di file che permette di selezionare il file di profilo <b>.dat</b> desiderato. Individuare il file di profilo alare, selezionarlo e premere <b>Open</b>.
</p>
<div class="center"><div class="floatnone"><a href="https://www.freecadweb.org/wiki/index.php?title=File:File_browser.png" class="image" title="File browser window for importing .dat airfoil files"><img alt="File browser window for importing .dat airfoil files" src="File_browser.png" width="859" height="496" /></a></div></div>
<h3><span class="mw-headline" id="Immettere_la_lunghezza_della_corda">Immettere la lunghezza della corda</span></h3>
<p>Dopo aver selezionato il file di profilo alare, si apre la finestra per inserire la lunghezza di corda. Può essere inserita qualsiasi lunghezza, in millimetri. Alla conferma del valore, la Macro produce il contorno (DWire) seguendo i punti descritti nel file <b>.dat</b> del profilo alare precedentemente selezionato, secondo la scala che è stata immessa per la lunghezza della corda.
</p>
<div class="center"><div class="floatnone"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Chord_length.png" class="image" title="Chord length dialog for import and scale macro v1.5"><img alt="Chord length dialog for import and scale macro v1.5" src="Chord_length.png" width="378" height="146" /></a></div></div>
<p>Ora il profilo alare, in scala corretta, dovrebbe essere pronto per essere utilizzato.
</p>
<h2><span class="mw-headline" id="Come_utilizzare_la_Versione_2">Come utilizzare la Versione 2</span></h2>
<p>La selezione del file avviene come per la versione 1.5. Con la versione 2 si può scegliere se il contorno del profilo alare risultante deve essere una linea DWire o una BSpline. Come per la versione 1.5, inserire la lunghezza della corda desiderata e in più selezionare il tipo di contorno.
</p>
<div class="center"><div class="floatnone"><a href="https://www.freecadweb.org/wiki/index.php?title=File:V2_scale.png" class="image" title="Version 2 Airfoil Import and scale dialog with choice of DWire or BSpline"><img alt="Version 2 Airfoil Import and scale dialog with choice of DWire or BSpline" src="V2_scale.png" width="378" height="189" /></a></div></div>
<h3><span class="mw-headline" id="Modificare_la_selezione_predefinita">Modificare la selezione predefinita</span></h3>
<p>Per ottenere che di default tutti profili importati e in scala vengano creati con <b>BSplines</b> piuttosto che con <b>DWires</b>, basta modificare la Marco. Questo viene fatto modificando la seguente riga:
</p>
<pre>##exampleCode##
self.radio1.setChecked(True) </pre>
<p><br />
- e modificarla con -<br />
</p>
<pre>##exampleCode##
self.radio2.setChecked(True) </pre><br />
<p>Una nota sulla procedura è inclusa nel codice della macro.
</p>
<h2><span class="mw-headline" id="La_Macro">La Macro</span></h2>
<h3><span class="mw-headline" id="Versione_1.5">Versione 1.5</span></h3>
<pre># # # #
#
# AIRFOIL IMPORT &amp; 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 &amp; 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() </pre>
<h3><span class="mw-headline" id="Versione_2">Versione 2</span></h3>
<div id="itsfree" style="text-align:center;color:black;background:#FDE0A8;margin:1em 7em;padding:0.5em 2em;border:2px solid #FF5706;"><b>Attenzione: questa Macro con versioni di FreeCAD precedenti alla versione 0.14 3077 non produce i risultati attesi quando si utilizza l'opzione BSpline e può provocare il blocco di FreeCAD e la perdita dei dati non salvati&#160;!</b></div>
<pre>
# # # #
#
# AIRFOIL IMPORT &amp; SCALE v2.
#
# Imports and scales an Airfoil in the form of a Draft Wire (DWire) or Basic Spline (BSpline)
#
# For FreeCAD Versions = or &gt; 0.14 Revision 3077
#
# Works best with OCC/OCE = or &gt; 6.7
#
# # # #
from PyQt4 import QtCore, QtGui
from PyQt4.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 &amp; 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 &amp; 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()
</pre>
<h3><span class="mw-headline" id="Version_2.1">Version 2.1</span></h3>
<p>Updated by mangtronix to use PySide instead of PyQt (used in older versions of FreeCAD)
</p>
<pre>
# # # #
#
# AIRFOIL IMPORT &amp; SCALE v2.1
#
# Imports and scales an Airfoil in the form of a Draft Wire (DWire) or Basic Spline (BSpline)
#
# For FreeCAD Versions = or &gt; 0.14 Revision 3703
#
# Works best with OCC/OCE = or &gt; 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 &amp; 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 &amp; 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()
</pre>
<h2><span class="mw-headline" id="Link">Link</span></h2>
<p>La discussione nel <a rel="nofollow" class="external text" href="http://forum.freecadweb.org/viewtopic.php?f=22&amp;t=5554&amp;p=45137&amp;hilit=Airfoil#p45137">Forum</a>
</p><p><a rel="nofollow" class="external text" href="http://aerospace.illinois.edu/m-selig/ads/coord_database.html#N">UIUC Applied Aerodynamics Group Departement of Aerospace Engineering</a>
</p>
</div>
</div>
</div><div class="printfooter">
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Macro_Airfoil_Import_%26_Scale/it&amp;oldid=241102">http://www.freecadweb.org/wiki/index.php?title=Macro_Airfoil_Import_%26_Scale/it&amp;oldid=241102</a>"</div>
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
</div>
</div>
<div id="mw-navigation">
<h2>Navigation menu</h2>
</body></html>