The second little one is when the script produces the airfoil, it also includes a "folder" in the tree view. Is there a way to not have it do that?
Thanks for any pointers you can offer.
Mark
Here is the macro as it stands at the moment. Looks like a couple of long lines got wrapped. -
Code: Select all
# # # #
#
# AIRFOIL IMPORT & SCALE v2.
#
# Makes a scaled airfoil from either a DWire or Bspline
#
# # # #
from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import QLineEdit, QRadioButton
import FreeCAD, FreeCADGui, Draft
import importAirfoilDAT
# Selcet .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 radio1.isChecked():
try:
scalefactor=float(self.s1.text())
f1=str(filename)
importAirfoilDAT.insert(f1,"Unnamed")
Draft.scale(App.ActiveDocument.DWire,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 radio2.isChecked():
try:
scalefactor=float(self.s1.text())
f1=str(filename)
importAirfoilDAT.insert(f1,"Unnamed")
points = FreeCAD.ActiveDocument.ActiveObject.Points
Draft.makeBSpline(points)
Draft.scale(App.ActiveDocument.BSpline,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
self.radio1.setChecked(True)
la.addWidget(self.radio1)
la.addWidget(self.radio2)
# Add OK box
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()