Help on Python functions

Hi all ,
I am new to python scripting with dynamo , the problem in a brief is that am trying to make a function that takes a point as a parameter , in the function am defining a point variable to use as a center like the following ::
def MyFunction(center , etc…):
centerpoint = Point.ByCoordinates(center)
now when i recall the function like
MyFunction((0,0,0) , etc…)
I got an error saying (expected point got tuple)!! why is it expecting point inside a point ?? shouldn’t it be expecting tuple !?
please help

Can you show your full script?
The Point.ByCoordinates doesn’t accept a list of numbers, it expects 3 explicit numbers. You can’t just use a list/tuple variable inside, but would need Point.ByCoordinates(centerX, centerY, centerZ)

If you have it set up like a list, you could do Point.ByCoordinates(center[0],center[1],center[2])

# Enable Python support and load DesignScript library
import clr
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
def makeCenter(center):
	return Point.ByCoordinates(center[0],center[1],center[2])

centerPoint = makeCenter((0,0,0))

# Assign your output to the OUT variable.
OUT = centerPoint




As @kennyb6 said, the inputs for your function aren’t of the correct type. If you are using a Dynamo OotB node inside a Python script, you can right click on the node in the graph and hit “help” to check which inputs are expected. If you are using a Python function, you can check online (say Google) to know exactly which inputs are expected.

Hope it helps

1 Like

Thank you very much for your help, it was useful, it’s just that am Familiar with python coding within rhino, and the way I uses works there perfectly, anyways thanks