Created NEW Macro : AeroFoil

Need help, or want to share a macro? Post here!
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Created NEW Macro : AeroFoil

Postby melwynfranciscarlo » Mon Mar 01, 2021 3:05 pm

I just created my very first FreeCAD Macro, titled AeroFoil.

A similarly existing macro is the Airfoil Import & Scale, which is very old, I reckon; also, it's limited in its functionality.
I simply added a whole lot more features to make the airfoil creation more fun, flexible, and do-it-all.

Image

Macro AeroFoil Wiki Page
Description : AeroFoil creates airfoil curves and faces using pre-defined models, algebraic functions, and DAT or CSV Files.

So, what do you think? Is it worth tying the knot with FreeCAD?
8-) MFC Boy: the one and only! 8-)
Syres
Posts: 1016
Joined: Thu Aug 09, 2018 11:14 am

Re: Created NEW Macro : AeroFoil

Postby Syres » Mon Mar 01, 2021 5:16 pm

melwynfranciscarlo wrote: Mon Mar 01, 2021 3:05 pm So, what do you think?
You can't assume every FreeCAD user has their macros in the default location, some of us have a proper data structure with macros, templates, GCode, FEM/CFD etc so I changed line 186 on my copy from :

Code: Select all

MD_ = App.getUserMacroDir() + "AeroFoil_UI_Files/AeroFoil_"
to:

Code: Select all

MD_ = FreeCAD.getUserMacroDir(True) + "/AeroFoil_UI_Files/AeroFoil_"
The difference on my Windows box is from:

17:12:46 C:\Users\JPS\AppData\Roaming\FreeCAD\Macro/AeroFoil_UI_Files/AeroFoil_

to:

17:12:46 E:/Data/FreeCAD/Macro/AeroFoil_UI_Files/AeroFoil_

I've not tested on Linux yet but will do later and report back.

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24267 (Git)
Build type: Release
Branch: master
Hash: b2ca86d8d72b636011a73394bf9bcdedb3b109b7
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Re: Created NEW Macro : AeroFoil

Postby melwynfranciscarlo » Mon Mar 01, 2021 5:28 pm

Syres wrote: Mon Mar 01, 2021 5:16 pm You can't assume every FreeCAD user has their macros in the default location, some of us have a proper data structure with macros, templates, GCode, FEM/CFD etc so I changed line 186 on my copy from :
...
I've not tested on Linux yet but will do later and report back.

Okay, thank you, Syres! I've noted that down.
After I receive all inputs, I'll make the changes in one-go.
8-) MFC Boy: the one and only! 8-)
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Re: Created NEW Macro : AeroFoil

Postby melwynfranciscarlo » Thu Mar 04, 2021 1:50 pm

Syres wrote: Mon Mar 01, 2021 5:16 pm You can't assume every . . .
. . .
I've not tested on Linux yet but will do later and report back.

I added your correction to my copy as well, and seeing that no other issues have turned up, I have submitted a PR.
8-) MFC Boy: the one and only! 8-)
User avatar
Zolko
Posts: 1355
Joined: Mon Dec 17, 2018 10:02 am

Re: Created NEW Macro : AeroFoil

Postby Zolko » Fri Mar 05, 2021 11:41 am

melwynfranciscarlo wrote: Mon Mar 01, 2021 3:05 pm I just created my very first FreeCAD Macro, titled AeroFoil.

So, what do you think? Is it worth tying the knot with FreeCAD?
Hello, nice effort, but there are some issues:

1) why do I have to tell where the lines start and where they end ? Is line #1 (as per a text editor) the first line, or is the first line the #0 as per python ? The built-in airfoil dat importer can figure this out alone. You could, for example, skip all lines beginning with # as comments, and read each line until an empty line is encountered)

2) I can't enter a chord larger than 10mm

3) the following data produces wrong results:

Code: Select all

# Airfoil   Z- 33   10.90%   alpha0= -3.04   Cm0= -.0653
  1.00000   .00000 
   .99686   .00030 
   .98747   .00123 
   .97199   .00290 
   .95069   .00542 
   .92394   .00887 
   .89223   .01329 
   .85611   .01862 
   .81618   .02478 
   .77307   .03161 
   .72739   .03889 
   .67977   .04637 
   .63078   .05380 
   .58100   .06092 
   .53096   .06746 
   .48116   .07318 
   .43208   .07785 
   .38409   .08125 
   .33758   .08331 
   .29293   .08394 
   .25049   .08310 
   .21058   .08078 
   .17350   .07702 
   .13951   .07189 
   .10884   .06551 
   .08172   .05801 
   .05830   .04958 
   .03873   .04042 
   .02309   .03080 
   .01145   .02101 
   .00381   .01147 
   .00026   .00275 
   .00000  -.00032 
   .00018  -.00209 
   .00069  -.00363 
   .00165  -.00503 
   .00308  -.00640 
   .00803  -.00968 
   .02048  -.01464 
   .03807  -.01889 
   .06059  -.02231 
   .08789  -.02484 
   .11973  -.02646 
   .15585  -.02719 
   .19592  -.02708 
   .23956  -.02621 
   .28633  -.02467 
   .33574  -.02252 
   .38732  -.01987 
   .44052  -.01690 
   .49473  -.01376 
   .54930  -.01060 
   .60357  -.00753 
   .65687  -.00467 
   .70854  -.00212 
   .75790   .00003 
   .80430   .00170 
   .84711   .00286 
   .88570   .00347 
   .91951   .00355 
   .94801   .00316 
   .97073   .00234 
   .98712   .00123 
   .99682   .00032 
  1.00000   .00000 

4) I use the Curves WB to re-sample my points when mixing different airfoils, it would be good to include those tools

5) sometimes I need upper and lower surfaces of airfoils (for wire-cutting for example), it would be good to have the option to automatically add the (0,0) point and split the upper and lower surfaces into 2 separate curves (combining this with the re-sampling of the points)

6) the UI seems to grab the mouse, is it really necessary ?
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Re: Created NEW Macro : AeroFoil

Postby melwynfranciscarlo » Fri Mar 05, 2021 12:59 pm

Zolko wrote: Fri Mar 05, 2021 11:41 am ...
6) the UI seems to grab the mouse, is it really necessary ?

Hello Zolko, thank you very much for your reply.

1. You don't necessarily have to input the line numbers. Leaving it at its default value at 0 (as there is no line number 0) should automatically figure it out. The 'add line numbers' feature is simply for those who want it; you don't have to use it.

2. Airfoils greater than 10mm are possible on my computer. I've set a minimum limit of 1mm, not a maximum. I've just tested your airfoil for a chord length of 10 yards, that is, 9144mm, and it worked. Could you share a screenshot if it shows any errors?

3. I see the wrong results, and I'm on it! I'll notify you when I figure it out.

4. Could you be specify the tools used? And by resampling, do you mean equidistant resampling of points on a curve?

5. Oh yes, like the split curve. I could work on that, sure.

6. Grab the mouse? I'm confused. The mouse cursor does not change other than the default and the text cursor modes.
8-) MFC Boy: the one and only! 8-)
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Re: Created NEW Macro : AeroFoil

Postby melwynfranciscarlo » Fri Mar 05, 2021 2:40 pm

Zolko wrote: Fri Mar 05, 2021 11:41 am 2) I can't enter a chord larger than 10mm

Oh yes, it seems that I may have strangely (unintentionally, I think) set the maximum value of the Spin Box to 99.99. So the maximum of the input in the UI file was set to less than 100.

I've corrected it to 1000.

Is that okay? I mean, beyond that, you could simply switch to cm, m, etc.
8-) MFC Boy: the one and only! 8-)
User avatar
Zolko
Posts: 1355
Joined: Mon Dec 17, 2018 10:02 am

Re: Created NEW Macro : AeroFoil

Postby Zolko » Fri Mar 05, 2021 2:42 pm

melwynfranciscarlo wrote: Fri Mar 05, 2021 2:40 pm I've corrected it to 1000.
that's 1m. Why not 100000 (100m) ? That would leave room for some extravangza
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Re: Created NEW Macro : AeroFoil

Postby melwynfranciscarlo » Fri Mar 05, 2021 4:41 pm

Zolko wrote: Fri Mar 05, 2021 2:42 pm
melwynfranciscarlo wrote: Fri Mar 05, 2021 2:40 pm I've corrected it to 1000.
that's 1m. Why not 100000 (100m) ? That would leave room for some extravangza

Haha, okay, I'll do that then.

Phew, Problem No. 3 has finally been solved. The issue was with the .xxx and -.xxx style of DAT points. The code was used to just 0.xxx and -0.xxx. Changed that now.
8-) MFC Boy: the one and only! 8-)
User avatar
melwynfranciscarlo
Posts: 81
Joined: Thu Feb 04, 2021 7:47 am
Location: Mumbai, India

Re: Created NEW Macro : AeroFoil

Postby melwynfranciscarlo » Tue Mar 09, 2021 5:51 pm

Zolko wrote: Fri Mar 05, 2021 11:41 am 5) sometimes I need upper and lower surfaces of airfoils (for wire-cutting for example), it would be good to have the option to automatically add the (0,0) point and split the upper and lower surfaces into 2 separate curves (combining this with the re-sampling of the points)

The Split feature has been added to the Macro. It has also been tested against your airfoil, and it works!
8-) MFC Boy: the one and only! 8-)