Bspline from table

Hello

is there an easy way to create bspline from tables? The tables are in text form (*.csv file).

With kind regards

It seems that this feature is not yet implemented. Nevertheless, you can still do this programmatically with Python script (you can see how to achieve this by creating one b-spline and dumping the study as a python script)

Thanks NabilG for the idea to use dump. That was new for me.
It seems to be difficult. Here is an excerpt (Example):

SketchBSpline_1_poles = [(-54.55246913580245, -10.59876543209877),
(-25.56172839506173, 32.41975308641976),
(6.858024691358021, 31.48456790123457),
(42.70679012345676, 25.56172839506173),
(0, 0)
]
SketchBSpline_1 = Sketch_1.addSpline(poles = SketchBSpline_1_poles)
[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5] = SketchBSpline_1.controlPoles(auxiliary = [0, 1, 2, 3, 4])
[SketchLine_1, SketchL …

It is missing the possibility of a run statement (“for i in range(…)”) for the
control points. That’s why I’m going to abandon the project.

With kind regards

luve

Why giving up? It is actually very easy, for instance:

def read_datas(file):
fileIn = open(file, ‘r’)
line = fileIn.readline() # in case of header
points = []
for line in fileIn:
x, y = line.split(‘;’)
points.append([float(x), float(y)])
fileIn.close()
return points

points = read_datas(os.path.join(path, ‘datas.csv’))

model.begin()
partSet = model.moduleDocument()

Create Sketch

Sketch_1 = model.addSketch(partSet, model.defaultPlane(“XOY”))

Create SketchBSpline

SketchBSpline_1_poles = points
SketchBSpline_1 = Sketch_1.addSpline(poles = SketchBSpline_1_poles)
model.do()
model.end()

 Hello Konyaro

thank you very much for your work. I need to get back into Phyton. I am trying.

Not solved I find the text form of the other commands:

Example from the last post:
“…
SketchBSpline_1 = Sketch_1.addSpline(poles = SketchBSpline_1_poles)
[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5] = SketchBSpline_1.controlPoles(auxiliary = [0, 1, 2, 3, 4]) …”

That’s why I had given up.

With kind regards

luve

Hello Konyaro

that was a very good idea from you. This idea only needed to be supplemented with Salome launch routines.
I have attached my simple example with a sine curve. I left out the data import.

Your contribution has inspired me to deal with Python again.

Thanks

luve
Test.py (1,9 KB)