smooth airfoil

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!
mario52
Veteran
Posts: 4698
Joined: Wed May 16, 2012 2:13 pm

Re: smooth airfoil

Post by mario52 »

hi
with my current macro:
1: copy your file and renamed in MH 45.txt and delete the first line "MH 45 9.85% ")
2: check "Neutral" and "BSplineCurve"
3: read your file click "Read"

for reverse the coordinates:
4: check "Reverse"
5: click the "Reuse" button (the coordinates are in memory )
5: select the wire and click "BSplineCurve" button

4: check "Neutral" check "Reverse" check "BSplineCurve"
5: read your file click "Read"

PS: my macro not scale the wire you must use the FreeCAD tools

if you want BSplineCurve as Chris_G and use my macro:
edit the macro in the Python editor of FreeCAD
on my macro: lines 980 to 994 are presented like this :

Code: Select all

                            #lineCreate = Part.BSplineCurve()                                          # OK avec courbes BSplineCurve 1
                            #lineCreate.interpolate(pp)#,False)                                        # OK avec courbes BSplineCurve 1
                            #lineCreate = Part.Edge(lineCreate)                                        # OK avec courbes BSplineCurve 1
                            #Part.show(lineCreate)                                                     # OK avec courbes BSplineCurve 1
                            #self.RB_02_03_BSplineCurve.setChecked(True)                               # OK avec courbes BSplineCurve 1
                            #text = "_BSplineCurve 1"                                                  # OK avec courbes BSplineCurve 1
                            #App.Console.PrintMessage("_BSplineCurve 1" + "\n")                        # OK avec courbes BSplineCurve 1
    
                            lineCreate = Part.BSplineCurve()                                          # OK avec courbes BSplineCurve 2
                            lineCreate.buildFromPoles(pp)                                             # OK avec courbes BSplineCurve 2
                            Part.show(lineCreate.toShape())                                           # OK avec courbes BSplineCurve 2
                            lineCreate = App.ActiveDocument.ActiveObject                              # OK avec courbes BSplineCurve 2
                            self.RB_02_03_BSplineCurve.setChecked(True)                               # OK avec courbes BSplineCurve 2
                            text = "_BSplineCurve 2"                                                  # OK avec courbes BSplineCurve 2
                            App.Console.PrintMessage("_BSplineCurve 2" + "\n")                        # OK avec courbes BSplineCurve 2
uncomment the lines 980 to 986 ( delete the # character ( !! just one character !! ))
and comment the lines 988 to 994 (select the lines 988 to 994 click right button mouse and click "Comment"
for obtain the result like this :

Code: Select all

                            lineCreate = Part.BSplineCurve()                                          # OK avec courbes BSplineCurve 1
                            lineCreate.interpolate(pp)#,False)                                        # OK avec courbes BSplineCurve 1
                            lineCreate = Part.Edge(lineCreate)                                        # OK avec courbes BSplineCurve 1
                            Part.show(lineCreate)                                                     # OK avec courbes BSplineCurve 1
                            self.RB_02_03_BSplineCurve.setChecked(True)                               # OK avec courbes BSplineCurve 1
                            text = "_BSplineCurve 1"                                                  # OK avec courbes BSplineCurve 1
                            App.Console.PrintMessage("_BSplineCurve 1" + "\n")                        # OK avec courbes BSplineCurve 1
    
#                            lineCreate = Part.BSplineCurve()                                          # OK avec courbes BSplineCurve 2
#                            lineCreate.buildFromPoles(pp)                                             # OK avec courbes BSplineCurve 2
#                            Part.show(lineCreate.toShape())                                           # OK avec courbes BSplineCurve 2
#                            lineCreate = App.ActiveDocument.ActiveObject                              # OK avec courbes BSplineCurve 2
#                            self.RB_02_03_BSplineCurve.setChecked(True)                               # OK avec courbes BSplineCurve 2
#                            text = "_BSplineCurve 2"                                                  # OK avec courbes BSplineCurve 2
#                            App.Console.PrintMessage("_BSplineCurve 2" + "\n")                        # OK avec courbes BSplineCurve 2
if this is complicate, here the Chris_G macro for reverse the coordinate

Code: Select all

obj = FreeCAD.ActiveDocument.getObject("DWire") 
pts = [v.Point for v in obj.Shape.Vertexes] 

import Part 
bs = Part.BSplineCurve() 
bs.interpolate(pts) 
Part.show(bs.toShape()) 
FreeCAD.ActiveDocument.ActiveObject.Label = "Normal"

pts.reverse()
bs = Part.BSplineCurve() 
bs.interpolate(pts) 
Part.show(bs.toShape()) 
FreeCAD.ActiveDocument.ActiveObject.Label = "Reverse"

(I do not know if the reverse corresponds to the desired g code)

EDIT: 29/05/2017 21h42 PARIS
modify the step 5: select the wire and click "BSplineCurve" button
EDIT: 30/05/2017 10h22 PARIS
modify for reverse

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
oeliks
Posts: 50
Joined: Fri May 26, 2017 4:54 am

Re: smooth airfoil

Post by oeliks »

Hi again :)

Now I have problem with this interpolation macro.


I was using import and scale macro 2.2
Freecad-daily update
Ubuntu 18.04
Attachments
Screenshot from 2019-07-10 15-30-35.png
Screenshot from 2019-07-10 15-30-35.png (162.76 KiB) Viewed 859 times
User avatar
Chris_G
Veteran
Posts: 2601
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: smooth airfoil

Post by Chris_G »

The name of the object has changed.
It should work by replacing "DWire" with "Wire" in the first line of the code :

Code: Select all

obj = FreeCAD.ActiveDocument.getObject("Wire")
pts = [v.Point for v in obj.Shape.Vertexes]
import Part
bs = Part.BSplineCurve()
bs.interpolate(pts)
Part.show(bs.toShape())
oeliks
Posts: 50
Joined: Fri May 26, 2017 4:54 am

Re: smooth airfoil

Post by oeliks »

No error is present :) but the results are not so good as before. What went wrong?

Import&scale macro 2.2
Ubuntu 18.04
Freecad daily update 0.19

.dat file is mh45 from aerofoiltools with deleted header "mh45 .... "

Edit.

Changing Tolerance :
bs.interpolate(points, Tollerance=0.0001)
And changing bs.interpolate to bs.approximate

This didnt work so well.
Attachments
Invalid .dat
Invalid .dat
Screenshot from 2019-07-11 15-38-29.png (662.78 KiB) Viewed 812 times
After interpolation
After interpolation
Screenshot from 2019-07-11 15-36-47 (1).png (193.13 KiB) Viewed 812 times
oeliks
Posts: 50
Joined: Fri May 26, 2017 4:54 am

Re: smooth airfoil

Post by oeliks »

Interpolation macro of closed wire gave me a open shape.

Best results I had was using import&scale macro v2.2, import as bspline. .dat file had to be edited, deleting first comment line, and changing 0 coordinates to 0.00000. Freecad -> preferences, decimal points = 5.
Changing in View window angular deflection = 3, deviation = 0,01 (Thank You wery much Chris_G).

This produces very smooth and closed bspline that can be further extrude.

Only thing that didn't worked was scaling operation of import&scale macro.
mario52
Veteran
Posts: 4698
Joined: Wed May 16, 2012 2:13 pm

Re: smooth airfoil

Post by mario52 »

hi
oeliks wrote: Mon Jul 15, 2019 4:33 am Only thing that didn't worked was scaling operation of import&scale macro.
i have upgraded the macro Version 2.1.2 now work with all FCVersion

you can install with AddonManager

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
Post Reply