.dat Airfoil importer = Wonderful Frustration

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
quick61
Posts: 3793
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

.dat Airfoil importer = Wonderful Frustration

Postby quick61 » Sun Sep 01, 2013 11:38 pm

I have been monkeying around with the .dat importer for the last few days. First, very shiny that this feature is in there. After working in XFLR5 (http://www.xflr5.com/xflr5.htm for Mac & Win, Linux versions from your distro), and tweaking a wing with just the right airfoil, it is great to have a CAD that will import those airfoils. Allowing me to build them into a 3D model that I can then export to be machined (laser cut / router cut / 3D printed). . . . But there's just one little hitch...

For those that are unfamiliar with the .dat files for airfoils, (like these – http://aerospace.illinois.edu/m-selig/a ... abase.html), they are standardized in a format of data points ranging from 0 to 1 in the X and -1 to 1 in the Y , split along the chord centerline. When imported into FreeCAD, this data is seen as fractions of 1mm. Not a very good size to be building parts for R/C / Ultralight / Full Scale aircraft. OK, just scale up the import. That would be just fine if the imported airfoil could be scaled, but the scaling tool does not actually scale the part. It creates an alleged clone of the part. I say alleged because it's not a real clone, IMO, and does not even play a good one on TV. If it were a real clone, I could select it and use the Draft to Sketch tool on it and have a properly sized sketch. However, invoking the Draft to Sketch tool creates a sketch from the original sub 1mm import. This makes things a bit more difficult, living in a country that is still stuck on imperial units and already having to convert between inches and millimeters is enough without having to add to that, tracking the decimal point through micrometers and nanometers. So now I start looking for a good way to work around this little problem.

My first search was for a script that would scale a sketch... Nope, na-da, none that I could find. Next I start thinking about making scaled alleged clones of the root and tip chords and lofting between them, then performing boolean operations to get the slots for spars, leading edge, trailing edge, and holes for wire, control rods and lightning. After which the part could be sliced at the appropriate stations with more boolean operations to produce the ribs. This is actually a good way to do this as it will produce accurate dimensions for the ribs at their assigned station when building a tapered wing. It is also the only way to do this as the alleged clone has no planar face to place a sketch on and do pocketing / padding operations, even if it were a constant chord wing section. So now all I need do is click on the slicer button, enter the number, width, and spacing of the slice and I'll be done.... Nope, na-da, nothing. No slicer function. OK, maybe theres a slicer script out there... Nope, can't find one of those either. So I'm back to a slow, manual work flow.

I hope no one takes this post as any sort of whining or the like, It is not! It is intended to inform the reader as to where I am with what I am trying to do and solicit hints, help, suggestions, links to scripts, etc..

Some thoughts on what might be useful for this and many other projects are :

1. An addition to the import script / GUI interface that would facilitate scaling of the .dat file as it was being created in the script. Something like the picture bellow. NOTE: not a working feature – just an artistic rendering of wishful thinking.
Image

2. A slicer that works similar to this Ruby script - http://sketchucation.com/forums/viewtop ... 57&p=16699 – that is a plugin for Sketchup. I use this plugin my own self when I can tolerate booting up the old winBox, and think it is one slick tool that has many uses far beyond producing ribs from wing sections.

Now, given that I know precious little beyond basic Python scripting and far, Far, FAR less about how to produce a GUI interface for interacting with said scripts, I can only offer my services for alpha / beta testing and the like, should anyone wish to attempt to write scripts for either of the above.

Here is a screenshot of what I am attempting to produce. Shot is of alleged clone, 1” (25.4mm) in length with orignal imported airfoil (as size comparison). To the alleged clones credit, modifying the orignal sketch does update the clone.

Image

Mark

EDIT: Should of probably thrown this in there somewhere -

OS: Ubuntu 12.04.3 LTS
Platform: 32-bit
Version: 0.14.2423 (Git)
Branch: master
Hash: e7111b4d1083ee9104c4b394b423e1f824ceba9b
Python version: 2.7.3
Qt version: 4.8.1
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.5.0
This post made with 0.0% Micro$oft products - GOT LINUX?
User avatar
quick61
Posts: 3793
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: .dat Airfoil importer = Wonderful Frustration

Postby quick61 » Mon Sep 02, 2013 2:24 am

Working further, looks like a loft is not such a good idea after all as doing so, then slicing it up results with missing faces on either side of the slice. So it would seem to be back to figuring out how to scale the sketch. either at the time of reading the .dat file, (probably the best and easiest way) of scaling the sketch somehow after it is extracted from the drawing.

Image

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
User avatar
quick61
Posts: 3793
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: .dat Airfoil importer = Wonderful Frustration

Postby quick61 » Mon Sep 02, 2013 7:03 am

Sense the last post, i am feeling a bit embarrassed. :oops: Figured out that the loft makes a shell by default and not a solid. once this was known, it was very short order before I found the "Convert to solid" command under the Part menu. No Icon for it, but it was still very quickly placed into my custom tool bar for the Part Workbench. Still the problem with the ends being non planar faces but I think I can take care of that by placing them a bit further apart for the loft and trim off the ends to have a 100% solid part. Things are looking up and it would seem that the thought of creating a slicer is again looking like a great idea.

Non planar face selected in snapshot. From that face to the first cut remains a shell, even after the loft was converted to a solid. :? All other faces are planar.

Image

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
User avatar
shoogen
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: .dat Airfoil importer = Wonderful Frustration

Postby shoogen » Mon Sep 02, 2013 9:13 am

You can scale your profile using the Draft/Clone command (stormtrooper icon).
User avatar
quick61
Posts: 3793
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: .dat Airfoil importer = Wonderful Frustration

Postby quick61 » Mon Sep 02, 2013 5:24 pm

shoogen wrote:You can scale your profile using the Draft/Clone command (stormtrooper icon).
Yes, I know, and it is in some ways better to use than that funky scale tool. Thanks for bringing that up. Scaling is not the problem though, the clone is the problem. One of a few I have run into. Like even though there is a tool to map a sketch TO a face, I have yet to find any tool or script to map a sketch FROM a face (or even make a copy of a single face). Maybe it can't be done? Perhaps I should break these problems down, prioritize them and ask over in the Help section. I thought about making the orignal post there but initially i was hoping to dredge up some scripts or the like that would help with what I am trying to do.

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
User avatar
shoogen
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: .dat Airfoil importer = Wonderful Frustration

Postby shoogen » Mon Sep 02, 2013 6:06 pm

mark,
to be honest, I don't understand what you are trying to achieve.
Do you really need a loft?
So you have to different airfoils that you need to connect. Otherwise i would start with an extrusion, (possible with a draft angle)
Do you want your section to be outlines (like for laser cutting) or do you want them to be solids?
User avatar
quick61
Posts: 3793
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: .dat Airfoil importer = Wonderful Frustration

Postby quick61 » Mon Sep 02, 2013 8:22 pm

shoogen wrote:mark,
to be honest, I don't understand what you are trying to achieve.
Do you really need a loft?
So you have to different airfoils that you need to connect. Otherwise i would start with an extrusion, (possible with a draft angle)
Do you want your section to be outlines (like for laser cutting) or do you want them to be solids?
OK, what I am trying to achieve. I wish to be able to produce accurate templates for a series of ribs in a tapered wing section. These ribs, while constantly changing size from one station to the next are held together and aligned (in all 3 axises) by linear dimensioned parts (spars). So simply just making a scaled copy and placing it at it's new station would result in an improperly dimensioned slot for the spar. If one were to think that it would be productive to just clone the airfoil to the scale, place them at their assigned stations, then lay in the spar and do a cut.... remember, they are alleged clones, and Freecad can not perform Boolean operations on alleged clones. Here is a snapshot of a cut operation done with an alleged clone acting a a face for the root rib. Notice that the spar piece has no affect up to the face, but performs as expected at all points beyond that face.

Image

So at the very least i need to find a way, script or what not, to directly scale a sketch, or at best, find a way to slice a solid and produce separate and individual parts that can be copied and moved. Neither of which it seems FreeCAD can do at this time out of the box. I was just wondering if anyone knows of any way to do this?

Oh, and yes, the individual ribs would then be laid out for machining operations, which may, and in all likelihood will include 3D printing. So the end product does kind of need to be a solid.

Mark
This post made with 0.0% Micro$oft products - GOT LINUX?
User avatar
shoogen
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: .dat Airfoil importer = Wonderful Frustration

Postby shoogen » Tue Sep 03, 2013 5:33 am

This is how you resize the imported airfoil. The result will be a 'face'

Code: Select all

>>> scalefactor=10.0
>>> import importAirfoilDAT
>>> importAirfoilDAT.insert("C:/Users/Me/Desktop/HS1620.DAT","Unnamed") # imports one Draft Wire named and labeled 'DWire'
>>> oldobject = App.ActiveDocument.DWire # imported object
>>> matrix=FreeCAD.Matrix()
>>> matrix.scale(scalefactor,scalefactor,scalefactor) #scale uniformly
>>> newshape=oldobject.Shape.copy() # extract the shape from the imported airfoil 
>>> newshape.transformShape(matrix) # scale the Shape
>>> newobject=App.ActiveDocument.addObject('Part::Feature','Airfoil1') #create a new Object for the resized shape
>>> newobject.Shape=newshape # assign the resized shape
>>> oldobject.ViewObject.Visibility=False #hide the old object
this uniform scaling will work for any shape.
If you preparing you airfoil for a loft you can directly assign the 'Wire' to the shape (instead of the 'Face') this will enable you to use the newly created object in the loft (without having to Draft/downgrade, extract the wire using the part builder)

Code: Select all

>>> newobject.Shape=newshape.OuterWire # assign the outer wire of the resized shape
The wire can be moved (and rotated) using a 'Placement'
Afterward you should be able to crate a loft. Please check the option to make the result a solid.
Last edited by shoogen on Tue Sep 03, 2013 3:58 pm, edited 1 time in total.
User avatar
shoogen
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: .dat Airfoil importer = Wonderful Frustration

Postby shoogen » Tue Sep 03, 2013 5:57 am

quick61 wrote:they are alleged clones, and Freecad can not perform Boolean operations on alleged clones.
I don't understand what you mean by alleged. Draft/Clones use transformGeometry() and can therefore be more error prone in booleans. But the airfoils only consist of line segments. And unlike for conic sections, affine transformations can be applied to line segments. There might be other reasons, why the boolean fails.
If booleans fail the first thing to do is to check the input Shapes using the Part/Analyze Geometry for Errors tool. if there are valid you should check the ShapeType. Most of the time you want to do booleans with solids. I you provide other ShapeType the result will be valid and well defined, but you will work on a shell instead of a solid without noticing. At last check for coincident geometry. Booleans should intersect and not touch. (This has been discussed many times i won't get into detail now)
If you provide and example file an experienced user could help asses those problems. But i can't tell you from your screen shots.
User avatar
quick61
Posts: 3793
Joined: Sat Aug 24, 2013 2:49 am
Location: u.S.A.

Re: .dat Airfoil importer = Wonderful Frustration

Postby quick61 » Tue Sep 03, 2013 3:54 pm

Thanks for that shoogen, unfortunately it did not scale for me. Imported the airfoil just fine but it did not scale. Tried it in both Linux and win. Both times i get this message -

>>> newobject.Shape=newshape # assign the resized shape
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'newobject' is not defined

As to my comments about alleged clones, IMO, if it were a "real" clone it would have all the same properties of the original, and it does not. The clone has no planar face, the original dose. The Convert Draft to Sketch tool will not work on the clone, works just fine on the original. The Boolean problem does seem to be MUCH improved with this last daily download (0.14 2425). I can not get it it to fail now, so that's a step in the right direction. (good job guys!).

So now that Boolean operations are working well with the ( alleged :twisted: ) clones, and they won't be getting in the way any more, I should probably try to turn my focus towards finding / creating a slicer that will take slices from a solid and make individual, simple, solid parts of those slices. i have done this by hand but it was slow going with only 4 parts taken from a single solid - see attached file - can't imagine doing it 20 - 100 times over.

Mark
Attachments
4 parts w_rods.fcstd
(445.07 KiB) Downloaded 58 times
This post made with 0.0% Micro$oft products - GOT LINUX?