loft thickness

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
duk
Posts: 55
Joined: Sun May 17, 2015 1:44 am

Re: loft thickness

Post by duk »

i used the dialogue box to create and past the text and execute it
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: loft thickness

Post by quick61 »

Did you use the latest version? That would be Version 2.1. What is the message in the Report view?

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
duk
Posts: 55
Joined: Sun May 17, 2015 1:44 am

Re: loft thickness

Post by duk »

this is a copy of the macro as it appears in freecad

# # # #
#
# AIRFOIL IMPORT & SCALE v1.5
#
# Imports and scales an Airfoil in the form of a Draft Wire (DWire)
#
# # # #


from PyQt4 import QtCore, QtGui
from PyQt4.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

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
Warning - Using this Macro with versions of FreeCAD lesser than 0.14, revision 3077 will not produce the expected results when using the BSpline option and can result in FreeCAD crashing and loss of unsaved data!
# # # #
#
# 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 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 & 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()

OS: Windows XP
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.16.5018 (Git)
Build type: Release
Branch: master
Hash: 5676c632f63b75955d3376f2fda09f4e892d490c
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
duk
Posts: 55
Joined: Sun May 17, 2015 1:44 am

Re: loft thickness

Post by duk »

a quick thanks to everyone, i'm making progress
new wing.FCStd
(22.8 KiB) Downloaded 31 times
User avatar
quick61
Veteran
Posts: 3803
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: loft thickness

Post by quick61 »

duk wrote:this is a copy of the macro as it appears in freecad
Wrong version for your version of FreeCAD, replace it with the one I linked to, version 2.1.

And when pasting macros and the like use the Code brackets like this -

Code: Select all

# # # #
#
# AIRFOIL IMPORT & SCALE v1.5
# 
# Imports and scales an Airfoil in the form of a Draft Wire (DWire) 
#
# # # #
 
 
from PyQt4 import QtCore, QtGui
from PyQt4.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
 
        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
Warning - Using this Macro with versions of FreeCAD lesser than 0.14, revision 3077 will not produce the expected results when using the BSpline option and can result in FreeCAD crashing and loss of unsaved data!
# # # #
#
# 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 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 & 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()

OS: Windows XP
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.16.5018 (Git)
Build type: Release
Branch: master
Hash: 5676c632f63b75955d3376f2fda09f4e892d490c
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
It makes for a neater and more compact post.

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
duk
Posts: 55
Joined: Sun May 17, 2015 1:44 am

Re: loft thickness

Post by duk »

i changed to 2.1, that's the one that works
Post Reply