Hello!
I'm trying to get a project script function to take a dataset as a parameter.
I've set up the function in the project script library as "def myFunction(dataset):", and I'm trying to call it from a binding on a custom property.
The binding value is a datset.
It shows as type BasicDataset when I check eith "return type(value)".
When I do a script transform to call the function:
def transform(self,value,quality,timestamp):
myResult = myScript.Scripts().myFunction(dataset = value)
I get the error:
TypeError: myFunction() got multiple values for key word argument 'dataset'
I don't know if this just isn't a thing I can do; or if I need to change the way I'm passing the dataset; or convert it somehow; or something else.
A quick search through the forum suggests I might need an import of something, but I don't really understand it.
Any pointers gratefully received!
Thanks
Have you tried it without the assignation?
myResult = myScript.Scripts().myFunction(value)
I have, yup.
It gives:
TypeError: myFunction() takes eactly 1 argument (2 given)
Why does Scripts()
have parentheses?
4 Likes
@pturmel more accurately I suppose it's myScript.myClass().myFunction
I've popped the function into a project script I've inherited that has a class definition.
It could be doing all sorts of things I don't understand.
The brackets are there because that's the syntax elsewhere in the project for calling functions from that script.
I don't actually know if they're needed!
Well, in that case, you would be calling a method, not a function, and methods need self
as their first argument (in the definition, not where called).
Consider sharing the whole script.
@pturmel
I have taken the function outside the class, and just made the call myScript.myFunction(dataset).
It is now working! Huzzah!
Thank you for the data point on methods as opposed to functions, it should make life easier and less trial-and-error based 