JacquesLucke / animation_nodes

Node based visual scripting system designed for motion graphics in Blender.
Other
2.29k stars 342 forks source link

Create a simplified way to extend animation nodes wihout making custom builds #1509

Closed prubini87 closed 4 years ago

prubini87 commented 4 years ago

Hi, I've been watching videos of people who have created custom nodes and have (re)built AN with said nodes, however, I was wondering if there's a way to make AN "extendable" in a simplified manner. I think it would be great if people could download compressed (zip) files containing other people's nodes and install them on top of AN existing nodes... That might eliminate the need to keep adding nodes to the existing repertoire, keeping AN very minimal, clean and solid, much like a framework, leaving all nodes that are too specific outside the core bundle, I guess, but close at hand for whoever wants to install extra nodes on the fly! I can already see an amazing repository of extra nodes of all sorts dream.

Has anybody been thinking about that? What are the current options for extending AN without making custom builds?

Those are thoughts and not at all a bug in AN. I couldn't find any other way to share them other than here. Please let me know if there's a better place!

Peace!

OmarEmaraDev commented 4 years ago

I think it is already possible to write an add-on that extends Animation Nodes. Haven't tried that before though, so I will give it a try, see what we need and get back to you.

OmarEmaraDev commented 4 years ago

Ok. So this is already possible. You just need to ensure Animation Nodes was loaded using addon_utils then you can define your nodes through absolute imports from the animation_nodes module.

We can write a guide and provide a skeleton code for those interested in writing extensions.

prubini87 commented 4 years ago

That's awesome news! Thanks @OmarEmaraDev, always providing quick feedback! 👍 It would be superb if there was a guide on how to do it. Perhaps we could add that to the official manual? Along the lines of "extending Animation Nodes"...

OmarEmaraDev commented 4 years ago

We published a preliminary guide in https://github.com/JacquesLucke/animation_nodes_manual/commit/e49de0fabbce72f6206ed8c68e936fa51e1a79b6. Should be deployed in a moment. Let us know if you have any feedback.

harisreedhar commented 4 years ago

Is it possible to extend datastructures and sockets?

OmarEmaraDev commented 4 years ago

@harisreedhar You may define your own sockets just like in Animation Nodes. Create a directory named sockets with an empty __init__.py file, and add your socket definition there.

What do you mean by extending data structures? Do you want to add more methods to FloatList for instance?

harisreedhar commented 4 years ago

I mean my own datastructure. Like actions for example

harisreedhar commented 4 years ago

For example if i want to create a datastructure Vector4DList is it possible?

OmarEmaraDev commented 4 years ago

It is possible, albeit hard at the moment. I will consider adding this to the guide. I wounder if shipping the headers with Animation Nodes will be enough to make this work, I will get back to you.

harisreedhar commented 4 years ago

Thanks @OmarEmaraDev One more thing, In the documention i saw custom cython functions are currently not supported. If we ship dependant files like datastructures, algorithms etc will it be possible to write cython functions ?

OmarEmaraDev commented 4 years ago

To clarify, you may write your own custom Cython functions, I just haven't described that in the documentation yet. I will probably do that at some point. However, the complication here is that you can't use the structures defined by Animation Nodes inside your Cython functions. To do that, you would need the pxd header files in Animation Nodes. So we first need to find a way to release those files to be used by developers.

OmarEmaraDev commented 4 years ago

@harisreedhar I added support for Cython extensions. Consult the documentation for more information: https://docs.animation-nodes.com/developer_guide/extensions/introduction/

Please let me know if you have any feedback.

harisreedhar commented 4 years ago

@harisreedhar I added support for Cython extensions. Consult the documentation for more information: https://docs.animation-nodes.com/developer_guide/extensions/introduction/

Please let me know if you have any feedback.

Hi, I need help. I got an error. terminal_error

My addon path: /home/hari/Desktop/test_AN_code/an_bluefox_extension

header path: /home/hari/Desktop/animation_nodes_headers

conf.json file:

{
    "Copy Target" : "/home/hari/.config/blender/2.92/scripts/addons",
    "Cython Include Paths" : ["/home/hari/Desktop/animation_nodes_headers"]
}

a test cython file: cython_file_code

OmarEmaraDev commented 4 years ago

@harisreedhar Seems like you have an old version of the cythonize.py file. Did you download that from latest master?

harisreedhar commented 4 years ago

@harisreedhar Seems like you have an old version of the cythonize.py file. Did you download that from latest master?

You're right. I downloaded files directly from master branch and it is working now. Thanks a lot for this.

OmarEmaraDev commented 4 years ago

@harisreedhar How did it go with the extension? Are you planning to release an extension containing your nodes?

harisreedhar commented 4 years ago

@harisreedhar How did it go with the extension? Are you planning to release an extension containing your nodes?

I have ported some custom nodes i created earlier as extension [link]. It is working fine. Headers are imported and Cython files are successfully compiled. The documentation was really helpful. One thing i didn't find is making custom socket types. Can you add that to documentation as well? It would be very helpful.

Yes i would like to release extension someday.

OmarEmaraDev commented 4 years ago

@harisreedhar That's good to hear. Custom sockets types are not special, just add a directory sockets like the nodes directory and add you sockets there. I just added that to the documentation anyway.

By the way, @3DSinghVFX was working on the workflow file to make it possible to grab the headers during compilation. Maybe you can as him for that so as not to add the headers to your extension's repository.

harisreedhar commented 4 years ago

@OmarEmaraDev Thank you. So no need to add headers on repository? That is cool. I'll ask him.

3DSinghVFX commented 4 years ago

@OmarEmaraDev and @harisreedhar Here is the worflow for Animation Nodes' extension that grab the headers of Animation Nodes during compilation https://github.com/3DSinghVFX/an_extra_nodes/blob/master/.github/workflows/build.yml. Add these lines to the existing workflow to grab the headers and extract them,

      - name: Download Animation Nodes' Headers
        uses: i3h/download-release-asset@v1
        with:
          owner: JacquesLucke
          repo: animation_nodes
          tag: master-cd-build
          file: animation_nodes_headers.zip
      - name: Extract Headers
        run: python -m zipfile -e animation_nodes_headers.zip ./
OmarEmaraDev commented 4 years ago

Thanks @3DSinghVFX!

harisreedhar commented 4 years ago

@OmarEmaraDev and @harisreedhar Here is the worflow for Animation Nodes' extension that grab the headers of Animation Nodes during compilation https://github.com/3DSinghVFX/an_extra_nodes/blob/master/.github/workflows/build.yml. Add these lines to the existing workflow to grab the headers and extract them,

      - name: Download Animation Nodes' Headers
        uses: i3h/download-release-asset@v1
        with:
          owner: JacquesLucke
          repo: animation_nodes
          tag: master-cd-build
          file: animation_nodes_headers.zip
      - name: Extract Headers
        run: python -m zipfile -e animation_nodes_headers.zip ./

Thank you✌️

OmarEmaraDev commented 3 years ago

@harisreedhar I missed something about sockets and have since update the documentation. You should update your __init__.py accordingly.

harisreedhar commented 3 years ago

@harisreedhar I missed something about sockets and have since update the documentation. You should update your __init__.py accordingly.

Now it is working thank you Omar