Plug function into python script

Maybe I have very simple question but I need help.

I have a function that called Basic_Parabola. I want to call this function into a python script and I want to give arguments and read results in that script. How can i develop that?

Hi @tahaoglua

Basic_Parabola is a DesignScript Function or a Python Function / Class ?
The DesignScript function cannot be called from Python.

You would have to open up your custom function and redefine it as something which the Python engine can interpret, either a .dll which you pull into the CLR or a .py which you load in via normal pythonic ways.

The .dyn on that is a misnomer, it’s a .dyf in this context. Either way you can open it up and look at the functions which it uses and reuse them in the Python script.

If the Parabola code is just a .py file (one of the suggestions by @jacob.small ) then you can reference it inside your Dynamo python environment simply like this, and call methods from within.

This example file has the ‘red’ code block python in a .py file at this location for loading.

“C:\Temp\custom_functions.py”

That said, really does depend on the initial code format in that custom node…

# Import Standard References
import clr,sys,os,importlib
# Path to reference python file to be added as a reference
reference_python_directory = os.path.normpath("C:\Temp")
sys.path.append(reference_python_directory)

# Name of the file
import custom_functions
 
# Reload on Run-Demand
importlib.reload(custom_functions) 

OUT = dir(custom_functions),custom_functions.example_range_output(10)