Creating B-Splines from imported ASC file
Forum rules
and Helpful information
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!
Also, be nice to others! Read the FreeCAD code of conduct!
Creating B-Splines from imported ASC file
Does FreeCAD have an option to convert points imported from ASC file into B-Splines automatically or we have to create them ourselves manually using B-Spline in draft WB?
Thanks - Hooshsim
Thanks - Hooshsim
Re: Creating B-Splines from imported ASC file
Maybe my own ignorance: what is an ASC file? Juwt ASCII text?
Re: Creating B-Splines from imported ASC file
@hooshsim forgot to tag you for above question. I don't know if it works if I edit.
Re: Creating B-Splines from imported ASC file
It's a very simple format of a point cloud where in each line you have three coordinates:
Example:
Code: Select all
0.0000 0.0000 0.0000
0.1234 1.0345 2.6578
....
-
- Veteran
- Posts: 3157
- Joined: Sat May 20, 2017 12:06 pm
- Location: Germany
Re: Creating B-Splines from imported ASC file
As far as I know there is no automatic method to create B-Splines from the point cloud.
The cloud is represented as one object in the model tree.
See the example below from the Dehler-Yacht.
How should the algorithm know which points to connect? Example taken from @hammax:
https://forum.freecadweb.org/viewtopic.php?f=13&t=74839
Re: Creating B-Splines from imported ASC file
It is not very complicated to convert such a file in something that FreeCAD can utilize to be passed to a BSPline method, already done for NACA airfoil profiles sone time ago, and more recently to scan some molecular Data from an ASCII file.
Sorry I have no computer at hand for some time to supply dome code. But probably earching for "airfoil" and my nickname probably will give some results.
Regards
Carlo D.
Sorry I have no computer at hand for some time to supply dome code. But probably earching for "airfoil" and my nickname probably will give some results.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
-
- Veteran
- Posts: 3191
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Creating B-Splines from imported ASC file
This is very easy. Import your ascii file splinedat.asc using the Points workbench. In the python console:
Code: Select all
import Draft
doc = App.ActiveDocument
shp = doc.getObject("splinedat").Points
Draft.makeBSpline(shp.Points)
doc.recompute()
Re: Creating B-Splines from imported ASC file
Surfaces can be made manually if points are not too many.
Code: Select all
import Draft
selobj = Gui.Selection.getSelection()
obj = selobj[0]
count = len(obj.Points.Points)
i = 0
comp = App.activeDocument().addObject("Part::Compound","Points_Compound")
for pt in obj.Points.Points:
p = Draft.makePoint(pt)
comp.Links += [p]
i += 1
print ("Nb points = "+str(count))
App.ActiveDocument.recompute()
- Attachments
-
- Capture.JPG (41.95 KiB) Viewed 692 times
-
- boat.FCStd
- (244.6 KiB) Downloaded 12 times
Re: Creating B-Splines from imported ASC file
Vincent,
What’s this code and how to use it. I’m not an expert on freecad. Please advice
Thanks-Hooshsim
What’s this code and how to use it. I’m not an expert on freecad. Please advice
Thanks-Hooshsim