Personal tools
You are here: Home Forum How to use Salome? newbie: MakeCurveParametric function

newbie: MakeCurveParametric function

Up to How to use Salome?

newbie: MakeCurveParametric function

Posted by fede Pacchiarini at October 21. 2015

hi all, 

how can local variables be passed to MakeCurveParametric function? here is my script fot the automatic generation of a parabola and i get:

RuntimeError: MakeSplineInterpolation : Can't evaluate the expressions

 

where is the error?

import sys

import salome

 

salome.salome_init()

theStudy = salome.myStudy

 

import salome_notebook

notebook = salome_notebook.NoteBook(theStudy)

sys.path.insert( 0, r'C:/Users/Syrio/Desktop')

 

import GEOM

from salome.geom import geomBuilder

import math

import SALOMEDS

 

 

geompy = geomBuilder.New(theStudy)

 

 

a= 1

b=-4

c= 5

f(x)= a*t**2+ b*t + c

tmin= 0

tmax= 100

    

O = geompy.MakeVertex(0, 0, 0)

OX = geompy.MakeVectorDXDYDZ(1, 0, 0)

OY = geompy.MakeVectorDXDYDZ(0, 1, 0)

OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)

Curve_1 = geompy.MakeCurveParametric("t", "dx", "0", tmin, tmax, 10, GEOM.Bezier, True)

geompy.addToStudy( O, 'O' )

geompy.addToStudy( OX, 'OX' )

geompy.addToStudy( OY, 'OY' )

geompy.addToStudy( OZ, 'OZ' )

geompy.addToStudy( Curve_1, 'Curve_1' )

 

 

if salome.sg.hasDesktop():

  salome.sg.updateObjBrowser(1)

Attachments

Re: newbie: MakeCurveParametric function

Posted by Saint Michael at October 21. 2015

Here is a fixed script

St.Michael

Attachments

Re: newbie: MakeCurveParametric function

Posted by fede Pacchiarini at October 21. 2015

HI,

first of all thank you for your prompt reply . But I must tell you that the program gives me the same error as before. :( And I just uploaded your script on the platform , I did not change anything about what you gave me


Re: newbie: MakeCurveParametric function

Posted by Saint Michael at October 21. 2015

I run the last attached script and it works. Please check that you load a right file.

St.Michael

Re: newbie: MakeCurveParametric function

Posted by Saint Michael at October 21. 2015

Maybe there was some bug in v7.4.0 you seem to use. I use v7.6.0.

St.Michael

Re: newbie: MakeCurveParametric function

Posted by Saint Michael at October 21. 2015

Try this variant of the script. I hope it will work.

St.Michael

Attachments

Re: newbie: MakeCurveParametric function

Posted by fede Pacchiarini at October 21. 2015

just downloaded and reloaded but i still have the same issues

 

FIle C.\.................... in RaiseFailed

                                    raise RuntimeError, Method_name + " : " + Operation.GetErrorCode()

MakeSplineInterpolatio : Canìt Evaluate the expression, please chek them!!!

 

maybe i have to set up something before start use variables? canìt understand

Re: newbie: MakeCurveParametric function

Posted by fede Pacchiarini at October 21. 2015

the variant works! thank you very much! do you suggest me to use the 7.6.0 version?

Re: newbie: MakeCurveParametric function

Posted by Saint Michael at October 21. 2015

I would not hurry ;)

St.Michael

Re: newbie: MakeCurveParametric function

Posted by Fynn at June 02. 2017

Hi, 

I just found 'MakeCurveParametric' and wonder if it is possible to feed it with predefined functions.

Basically instead of:

geompy.MakeCurveParametric( str(L), "t*cos(t)", "t*sin(t)", startArc, endArc, 100, GEOM.Interpolation, theNewMethod=True)

I want:
def funcX(t):
return L
 
def funcY(t):
return t*cos(t)
 
def funcZ(t):
return t*sin(t)

geompy.MakeCurveParametric( funcX, funcY, funcZ, startArc, endArc, 100, GEOM.Interpolation, theNewMethod=True)
 
Is there a work around for this?
 
cheers,
Fynn

Re: newbie: MakeCurveParametric function

Posted by Saint Michael at June 02. 2017

Hi

This should work if a script is launched in the Python console and won't work in batch mode.

Note that you are to pass strings to MakeCurveParametric() and not functions them-self:

geompy.MakeCurveParametric( "funcX", "funcY", "funcZ", ... #note the quotation marks

St.Michael

Powered by Ploneboard
Document Actions