"Click" Buttons in Duik in a Script

General help and tips
Forum rules
Please read these rules and advices before posting.
  • Before you ask any question about a tool, to avoid duplicates, please:
    1. Search for a solution in the available guides and documents.
    2. Some video tutorials are available.
    3. Maybe you can find an answer in the frequently asked questions (FAQ).
    4. You can make a search to see if your question has already been asked.
    • Thank you for giving a detailed and precise title to your topics, to help searching in the future.
    • We're very few people to manage this forum, please be patient if we're a bit long to answer.
    • Don't hesitate to answer to other people's questions! The goal of this forum is not only to have the Rainbox team answer users' questions, but to have everyone sharing and helping each other.
    • Finally, please always be polite, and keep in mind that all we want is sharing techniques and knowledge, helping each other.
Post Reply
schwarzer kater
Posts: 1
Joined: Sat Jul 20, 2019 9:00 pm

"Click" Buttons in Duik in a Script

Post by schwarzer kater » Wed Aug 28, 2019 12:04 pm

Hi everyone! :-)

TLTR: I'm looking for a way to "click Duik buttons" with a jsx script.

At the moment I work on creating a custom macro keyboard for use with AfterEffects and of course Duik.
custom keyboard.jpg
custom keyboard.jpg (102.73 KiB) Viewed 93 times
My knowlegde of extendscript is limited, though I figured out that I can use DuAEF to include/reproduce Duik functionality in my script.

For example I have a key to create a spine structure. I want to mimic Duik's behaviour as close as possible, so I dug a bit into the code and basically tried to copy the code for what Duik does when creating a spine.

Here's my solution so far:

Code: Select all

#include DuAEF_no_bin.jsxinc
function spine()
{
	var comp = DuAEF.DuAE.Project.getActiveComp();
	if (!comp) return;
	app.beginUndoGroup('Duik | ' + "Create spine structure");
	DuAEF.DuAE.Project.setProgressMode(true);
	DuAEF.Duik.Structure.createSpine(1,2,1,true);
	DuAEF.DuAE.Project.setProgressMode(false);
	app.endUndoGroup();
}
While this 'kinda works', the original function is more sophisticated, and takes into consideration spine options and other stuff. Also if the code changed with a new release I would have to manually update every function I create this way to reflect the changes.

So what (I think) I'm looking for is a way to call for example

Code: Select all

ui_spineValidButton_clicked(true);
inside the active duik panel and have it do its thing while respecting the corresponding settings.

Any insight on how this could be achieved is highly appreciated.


PS: I have another plugin (SortIt by EyeDesyn) that allows to execute functionality via a keyboard shortcut. There is one .jsx file per shortcut (and the shortcut gets added in AE to execute the corresponding script). Each .jsx contains only a few lines of code like this:

Code: Select all

#targetengine "sort-it";
try{
    groupLayersShortcut.pressed = true;
}catch(err){  
}
To my understanding the "targetengine" allows the script to have access to the same variables and objects as the main script that has the panel and functionality. Unfortunately I haven't figured out how the "action side" of this works since the main script is in binary format.

Maybe if I figured out how it works for this plugin it might bring me closer to do it for Duik. :-)

User avatar
Duduf
Posts: 650
Joined: Mon Jun 20, 2016 2:59 pm

Re: "Click" Buttons in Duik in a Script

Post by Duduf » Wed Aug 28, 2019 12:25 pm

Hi!

You've come at the right moment ;)
I'm working on this kind of stuff, not for shortcuts, but for a command line, like this:
https://www.youtube.com/watch?v=0Zc4_XF1YeM


For this functionnality, I have the same needs as you, i.e. a function for each button. And As soon as I have this, I'll think of a way to pass options and not just 'click' buttons, but that's a second milestone.

So, where I am:
I'm not going to "expose" the functions or anything else from Duik itself, because I don't want to "pollute" the global namespace. I have another approach which is to store the functions used by Duik in a separate file, which could be included in any other script, which will provide all these functions to be reused.

I'm in the middle of this process, and it will be testable/available quite soon, I hope.
The idea will just to

Code: Select all

#include Duik_functions.jsxinc
at the beginning of your script, something like that. That just means when a new version of Duik is released, you'll have to get the new versions of these files, that's all.

User avatar
Duduf
Posts: 650
Joined: Mon Jun 20, 2016 2:59 pm

Re: "Click" Buttons in Duik in a Script

Post by Duduf » Wed Aug 28, 2019 12:26 pm

Duik is already split into several files, for modularity, I'm just extending this concept:

https://github.com/Rainbox-dev/DuAEF_Du ... k_required

User avatar
Duduf
Posts: 650
Joined: Mon Jun 20, 2016 2:59 pm

Re: "Click" Buttons in Duik in a Script

Post by Duduf » Wed Aug 28, 2019 12:28 pm

This is what allows me to develop these kind of features:

https://www.youtube.com/watch?v=8-qkyofGL2Q

where each panel is a stand-alone one and does not even actually need the main Duik panel, but all panels do share the same source anyway.

User avatar
Duduf
Posts: 650
Joined: Mon Jun 20, 2016 2:59 pm

Re: "Click" Buttons in Duik in a Script

Post by Duduf » Sat Aug 31, 2019 5:24 pm

I have some very fresh news!

I've made an API available (it's really fresh, let me know if anything goes wrong or if you find any bug)

It's quite simple:
Just download the library there:
https://github.com/Rainbox-dev/DuAEF_Du ... e/Duik-API

Then you can include it in your script, and have an easy access to Duik methods. For example, this is how to create a Hominoid Structure (what the hominoid button does):

Code: Select all

//encapsulate everything to avoid global variables !important!
(function(thisObj) {

    //include the API
    #include 'Duik16_api.jsxinc'

    // Create a hominoid structure
    // The whole API is contained in the 'Duik' object
    // but the DuAEF framework is also made available in its own object
    Duik.structures.mammal();

})(this);

User avatar
Duduf
Posts: 650
Joined: Mon Jun 20, 2016 2:59 pm

Re: "Click" Buttons in Duik in a Script

Post by Duduf » Sat Aug 31, 2019 5:24 pm

All the available methods are documented there:
http://duaef-docs.rainboxlab.org/Duik-API/Duik.html

Utam7623
Posts: 1
Joined: Tue Sep 17, 2019 6:25 am

Re: "Click" Buttons in Duik in a Script

Post by Utam7623 » Tue Sep 17, 2019 6:27 am

Wow.. Find something new.. Nice thread...

Post Reply