Code: Select all
OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: English/United States (en_US)
Installed mods:
* Curves 0.5.1
* sheetmetal 0.2.50
2. Problem Description
I need to create a couple of BSplines on a plate. The coordinates of the B-Splies are imported from txt file. First, to keep it simple, I decided that every B-Spline would have only three points with X, Y, and Z coordinates. My code looks like that:
Code: Select all
##### Start reading from a file
if (fname[0] != ""):
f = open(fname[0], "r")
for line in f :
IsData = line.split(",")
x_start1 =float(IsData[0])
y_start1 = float(IsData[1])
z_start1 =float(IsData[2])
x_start2 =float(IsData[3])
y_start2 = float(IsData[4])
z_start2 =float(IsData[5])
x_start3 =float(IsData[6])
y_start3 = float(IsData[7])
z_start3 =float(IsData[8])
### Begin command Std_Workbench
Gui.activateWorkbench("DraftWorkbench")
### End command Std_Workbench
####### Creating Bspline
import Draft
points = [FreeCAD.Vector(x_start1, y_start1, z_start1), FreeCAD.Vector(x_start2, y_start2, z_start2), FreeCAD.Vector(x_start3, y_start3, z_start3)]
spline = Draft.make_bspline(points, closed=False, face=True, support=None)
Draft.autogroup(spline)
App.getDocument('Unnamed').recompute()
######## End Code
Ps. I have attached the whole working macro(with the B-Splines with 3 points each) The FCstd file, which the macro generates, and an example of the Input File. The Input file comes from an Abaqus Simulation and could contain a big number of points for the B-Spline. For this reason, my solution with x_start1,2,3 is not very practical.