opentoonz / opentoonz_docs

OpenToonz User Manual
http://opentoonz.readthedocs.io
28 stars 26 forks source link

ToonzScript API documentation #187

Open Kristianfriis opened 8 months ago

Kristianfriis commented 8 months ago

Ask a question related to OpenToonz

Hi there, Just a quick question about the documentation for scripting in Opentoonz.

Is the list of classes and methods complete? The reason I ask is, I obtained some documentation for ToonzScript in Toonz, which has a lot more API's one could tap into.

I have an idea for a tool that might help me when using Opentoonz, but it only looks to be possible according to the Toonz scripting API documentation and not OpenToonz.

Of course I understand that the API might not be the same, but was just curious :)

RodneyBaker commented 8 months ago

Hi @Kristianfriis Most of the ToonzScript documentation (for Toonz) works the same as with Opentoonz although that is quite limited. Perhaps you gained access to some additional documentation that isn't historically or publicly availalable but I suspect it's the same information that has made its way into Opentoonz documentation.

Some of the scripts appears to work... some do not. It isn't entirely clear (to me) why although some of that might just be my poor lack of understanding.

If you can share some of the script you have in mind we can certainly look into it and where the script engine might be broken perhaps that can even be fixed.

Opentoonz has gained a few scripting capbilities the older Toonz implementation didn't have such as some command line interfacings/options. Most of my attempts to use those however did not succeed.

Others who have delved more deeply into that area of the code should be able to answer your question with better detail but I want to let you know the generalized answer which is that the scripting should largely be the same for Toonz and Opentoonz... although very limited in scope.

I'm looking for a good excuse to investigate Toonz scripting again so please do share your thoughts on how you hope to move forward. The more interest there is in scripting the more likely we'll see improvement.

Kristianfriis commented 8 months ago

Hi @RodneyBaker

Okay, I have done some trial runs, but nothing extensive yet. Since it is a little bit touch and go, whether it works or not, I will simply try and build the script that I think will help me.

I have never touched C++ , so I am hoping I can accomplish what I want through scripting.

I will share it as soon as I have something ready'ish :smiley:

RodneyBaker commented 8 months ago

I should have said more about this as I have always been intereseted in toonzscript and from time to time discover new things about it. I also easily forget what I've learned!

Some time back I ran across this gem that uses python to create scripts/assist Opentoonz:

https://github.com/kogaki/toonzscript_music/tree/master

All this to suggest that the use of python... and even AI approaches... may be a great way to plus up Opentoonz scripting.

Please do share any and all you discover as we may yet get scripting going more fully yet.

Credit and thanks to: keisuke ogaki (@kogaki)

RodneyBaker commented 8 months ago

@Kristianfriis If you type "for (x in this.Scene) print(x);" into the Script console you get a long list of recognized terms/words which I must assume come from Qt's scripting environment. Please see attached for the terms I get in the output.

There are about 1150 words.

In my estimation this does not suggest all can be used in scripting... or does it.

RecognizedWords.txt

RodneyBaker commented 8 months ago

I'm currently having problems running any script in Opentoonz so I need to investigate.

Update: I had forgotten that OT only recognizes/runs scripts from the stuff/library/scripts directory of which there is none by default... although there are script directories automatically created in other places. Scripts stored there must be copied into a scripts directory in the library.

Still not able to fully run scripts unfortunately.

Update: Not sure what was going on but scripting is running just fine now. Very strange that it wasn't.

RodneyBaker commented 2 months ago

Here of late I have found the regular Opentoonz documenation to have some really good information on toonzscript. Much of it I had read before but the information never sank in. Lately however it has started to make a lot more sense.

Here's a link to that: https://opentoonz.readthedocs.io/en/latest/toonzscript.html?

The link to original scripts on the toonz site probably won't work but it can be pulled up using the wayback machine at archive.org.

@Kristianfriis I'm not sure how your research into toonzscript has been going but I'm curious.

RodneyBaker commented 1 month ago

Transferring this discussion to OT-docs