Is there a way to use a class in a python node that I have defined in another node before?
May I ask what class did you define ?
Basically we can do it.
I am trying to write a code that would generate architectural layouts.
A single Python Script node becomes bulky and inconvenient to use. So I want to use several nodes for diferent purposes and functionality.
Some of the classes i want to define are for “A* search” algorythm described here:
You can pass the class to the OUT variable and use it as an input in your other nodes.
Your first node may be this:
class MyClass(): pass OUT = MyClass # Do not instantiate this class.
And your second node could be this:
MyClass = IN # Assume you have passed the class to the first input. my_inst = MyClass() # Instantiate the class only once we have assigned it to a variable.
It is a very interesting algorithm. Keep up good work man. You can define your class in another python (.py file) and save all of those in one specific directory (in my example, I put in D:\ - which I marked by number 1 in the picture).
Then you can call it from python script inside dynamo (marked by number 2 in the picture).
I hope it could help.
Interesting method—much more pythonic too.