Here is an example script, that work in the python console.
Update the Curves workbench, if you had already installed it, because I pushed a fix this morning.
Code: Select all
import FreeCAD
from FreeCAD import Vector
import Part
# Create the curve network
poles0 = [Vector (0.0, 0.0, 0.0), Vector (0.16666666666666666, 0.0, 0.20000000794728598), Vector (0.49999999999999994, 0.0, 0.40000001589457196), Vector (0.8333333333333334, 0.0, 0.20000000794728598), Vector (1.0, 0.0, 0.0)]
weights0 = [1.0, 1.0, 1.0, 1.0, 1.0]
knots0 = [0.0, 0.5830951956177974, 1.1661903912355949]
mults0 = [4, 1, 4]
periodic0 = False
degree0 = 3
rational0 = False
bs0 = Part.BSplineCurve()
bs0.buildFromPolesMultsKnots(poles=poles0, mults=mults0, knots=knots0, periodic=periodic0, degree=degree0, weights=weights0, CheckRational=rational0)
obj0 = FreeCAD.ActiveDocument.addObject("Part::Spline","BSplineCurve0")
obj0.Shape = bs0.toShape()
poles1 = [Vector (0.013121589026499694, 0.7915876947955887, 0.0008571221601094414), Vector (-0.00885599845935274, 0.7914868593215942, 0.40897222572543346), Vector (0.06419121554803943, 0.7914868593215942, 0.9506049970258048), Vector (0.4267428298127499, 0.7914868593215942, 0.5416327713003715), Vector (0.7273027300834656, 0.7914868593215942, 0.0)]
weights1 = [1.0, 1.0, 1.0, 1.0, 1.0]
knots1 = [0.0, 0.7053976507426758, 1.6396089746603792]
mults1 = [4, 1, 4]
periodic1 = False
degree1 = 3
rational1 = False
bs1 = Part.BSplineCurve()
bs1.buildFromPolesMultsKnots(poles=poles1, mults=mults1, knots=knots1, periodic=periodic1, degree=degree1, weights=weights1, CheckRational=rational1)
bs1.getKnots()
obj1 = FreeCAD.ActiveDocument.addObject("Part::Spline","BSplineCurve1")
obj1.Shape = bs1.toShape(bs1.FirstParameter, bs1.LastParameter)
poles2 = [Vector (-0.29265061020851135, 1.7891597747802734, 0.0), Vector (0.556077287533451, 1.7891597747802734, 0.7004100558512543), Vector (1.2192605936714151, 1.7891597747802732, 0.9304442719319388), Vector (1.2656674010425126, 1.7891597747802734, 0.23003421608068433), Vector (1.2394413948059082, 1.7891597747802734, 0.0)]
weights2 = [1.0, 1.0, 1.0, 1.0, 1.0]
knots2 = [0.0, 1.5852100266723423, 2.105837254626154]
mults2 = [4, 1, 4]
periodic2 = False
degree2 = 3
rational2 = False
bs2 = Part.BSplineCurve()
bs2.buildFromPolesMultsKnots(poles=poles2, mults=mults2, knots=knots2, periodic=periodic2, degree=degree2, weights=weights2, CheckRational=rational2)
bs2.getKnots()
obj2 = FreeCAD.ActiveDocument.addObject("Part::Spline","BSplineCurve2")
obj2.Shape = bs2.toShape()
poles3 = [Vector (0.0, 0.0, 0.0), Vector (0.01980706605738829, 0.13102204117622993, 0.03582234726635581), Vector (0.04193204614098622, 0.39521243838553644, 0.05609202982516635), Vector (0.011570412468109364, 1.0063177946409716, -0.02655385582891836), Vector (-0.12865621642847969, 1.4740525911095985, -0.12251780016751808), Vector (-0.29265061020851135, 1.7891597747802734, 0.0)]
weights3 = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
knots3 = [0.0, 0.55, 1.841346800327301]
mults3 = [4, 2, 4]
periodic3 = False
degree3 = 3
rational3 = False
bs3 = Part.BSplineCurve()
bs3.buildFromPolesMultsKnots(poles=poles3, mults=mults3, knots=knots3, periodic=periodic3, degree=degree3, weights=weights3, CheckRational=rational3)
obj3 = FreeCAD.ActiveDocument.addObject("Part::Spline","BSplineCurve3")
obj3.Shape = bs3.toShape()
FreeCAD.ActiveDocument.recompute()
poles4 = [Vector (0.37568899989128113, 0.0, 0.2814561426639557), Vector (0.1979298550637957, 0.2528165565557051, 0.5073158012737045), Vector (0.012426622785748864, 0.8217413994502759, 0.8116662306235015), Vector (0.25350408566703514, 1.4418752936204768, 0.7220463662761115), Vector (0.5054633617401123, 1.7891597747802734, 0.5606870651245117)]
weights4 = [1.0, 1.0, 1.0, 1.0, 1.0]
knots4 = [0.0, 0.9339859674161192, 2.0140618136101445]
mults4 = [4, 1, 4]
periodic4 = False
degree4 = 3
rational4 = False
bs4 = Part.BSplineCurve()
bs4.buildFromPolesMultsKnots(poles=poles4, mults=mults4, knots=knots4, periodic=periodic4, degree=degree4, weights=weights4, CheckRational=rational4)
obj4 = FreeCAD.ActiveDocument.addObject("Part::Spline","BSplineCurve4")
obj4.Shape = bs4.toShape()
poles5 = [Vector (1.0, 0.0, 0.0), Vector (0.7962455246105475, 0.23471487235329058, -0.07387134852685648), Vector (0.6630578583047347, 0.6931604531973199, -0.02306488701337041), Vector (0.8347851190761894, 1.346445916688191, 0.09673176665963677), Vector (1.0782930244160058, 1.6595823128097014, 0.07573943536620759), Vector (1.2394413948059082, 1.7891597747802734, 0.0)]
weights5 = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
knots5 = [0.0, 0.837147057056427, 1.3702200651168823, 1.9922663569450378]
mults5 = [4, 1, 1, 4]
periodic5 = False
degree5 = 3
rational5 = False
bs5 = Part.BSplineCurve()
bs5.buildFromPolesMultsKnots(poles=poles5, mults=mults5, knots=knots5, periodic=periodic5, degree=degree5, weights=weights5, CheckRational=rational5)
obj5 = FreeCAD.ActiveDocument.addObject("Part::Spline","BSplineCurve5")
obj5.Shape = bs5.toShape()
# Create the Gordon surface
import gordon
gordon = gordon.InterpolateCurveNetwork([bs0,bs1,bs2],[bs3,bs4,bs5],0.1,0.001)
Part.show(gordon.surface().toShape())