Let's suggest new API features

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Stan
Posts: 199
Joined: Sun Apr 19, 2009 3:22 pm

Let's suggest new API features

Post by Stan »

Hey fellow scripters, let's dream out loud and let the developers know how we see the Moho's API can be improved!

I spoke with my friends A.Evseeva and KuzKuz, and we came up with a list of API features and bugfixes we'd love to see implemented in the future releases.

New API features:
  • Add the moho object to the UpdateWidgets and HandleMessage methods of the non-modal dialogs.
  • New type of scripts - panel script. A GUI panel that would always be shown, similar to the Style panel.
  • An ability to add custom animation channels. Similar to LayerData, but animatable.
  • M_Curve:Curvature(id) returns AnimVal, but the GetWeight and GetOffset return numbers. It would be nice to have an ability to get the AnimChannels for them as well.
  • Simple dialog boxes, like javascript's prompt and confirm.
  • Currently, GUI buttons only support the Alt modifier. It would be nice to also have the Shift and Ctrl.
  • An ability to sync reference channels, all together or separately.
  • API access to all parameters of Shape Style, including the image texture.
  • An ability to change the ImageButton's image on the fly.
  • An ability to read (or even change) the internal values of the Matrices.
  • Something similar to fPos (a position after the influences of all smart bones), but for all applicable channels.
  • An ability to get the color of an individual pixel in a raster image.
  • Raster vectorization (Draw -> Trace Image) without opening a dialog box, with ability to set the parameters via the API.
  • PSD import without opening a dialog box, with ability to set the parameters via the API.
  • An ability to read a PSD file and get its structure.
  • API access to all Menu commands.
  • JSON file parser.
  • External access to Moho's API (for example, Maya can do that).
  • Official up-to-date API documentation.
Bugs:
  • When selecting layers programmatically, the IsRelevant/IsEnabled methods are not being called, so the Tool panel doesn't update.
  • The Interval property of the vector layer doesn't have the API equivalent.
    Image
  • When bones are moved programmatically and the selected layer is a vector one, the Undo operation works incorrectly with PrepMultiUndo.
  • Moho crashes when shape.fMyStyle.fFillCol:ActionByName("actionName") is used.


Anyone else?
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
User avatar
synthsin75
Posts: 9981
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Let's suggest new API features

Post by synthsin75 »

I don't have any to add off the top of my head, but I hope you don't mind me commenting on yours.
Stan wrote: Sat Feb 20, 2021 5:40 am Add the moho object to the UpdateWidgets and HandleMessage methods of the non-modal dialogs.
Absolutely. We can technically already give the moho object to these, but you have to define a variable, in DoLayout, for each method you want to use, and moho.frame is always the frame when the dialog/menu is initiated.
New type of scripts - panel script. A GUI panel that would always be shown, similar to the Style panel.
Technically a modeless dialog can do this, but with the added hurdle of relaying specific moho methods to it. So adding the moho object to GUI structure functions would really help that.
An ability to add custom animation channels. Similar to LayerData, but animatable.
This is probably my #1 request, as it would mean scripts could store animated data for layer script use. Right now I'm repurposing a switch layer AnimString channel, but it would be amazing to add a channel to the layer itself and choose the channel type.
An ability to change the ImageButton's image on the fly.
Technically possible now, but requires going to/from frame zero and back to redraw. Definitely need a tool option layout redraw function.
JSON file parser.
I think I have a JSON beautify Lua script somewhere (requires Python installed, I think). Might be a good start.
EDIT: Here it is: https://sites.google.com/site/synthsin/ ... ects=0&d=1
Last edited by synthsin75 on Tue Feb 23, 2021 3:25 am, edited 1 time in total.
User avatar
KuzKuz
Posts: 483
Joined: Mon Aug 19, 2013 5:12 pm
Location: Ukraine

Re: Let's suggest new API features

Post by KuzKuz »

It would be nice to have a method to refresh the reference layers. If you move points using the API when the group layer is selected, the reference layers do not recognize that the points on the original layers have been moved.
User avatar
Lukas
Posts: 1297
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Let's suggest new API features

Post by Lukas »

Nice list!
Stan wrote: Sat Feb 20, 2021 5:40 am
  • Add the moho object to the UpdateWidgets and HandleMessage methods of the non-modal dialogs.
  • New type of scripts - panel script. A GUI panel that would always be shown, similar to the Style panel.
These are on the top of my list too. This would multiply Moho's potential for sure.
User avatar
hayasidist
Posts: 3528
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Let's suggest new API features

Post by hayasidist »

synthsin75 wrote: Sat Feb 20, 2021 7:23 am I don't have any to add off the top of my head, but I hope you don't mind me commenting on yours.
Stan wrote: Sat Feb 20, 2021 5:40 am An ability to add custom animation channels. Similar to LayerData, but animatable.
This is probably my #1 request, as it would mean scripts could store animated data for layer script use. Right now I'm repurposing a switch layer AnimString channel, but it would be amazing to add a channel to the layer itself and choose the channel type.
oh yes yes yes ...
but not so much a new API feature more a new core function - extend scriptdata (as implemented for layers) for objects such as shapes, curves, bones ... and now make that an animatable property

e.g. shape:ScriptData:Set("myKeyName", value, frame)


(BTW use scriptdata not layerdata)
User avatar
SimplSam
Posts: 1048
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: Let's suggest new API features

Post by SimplSam »

I don't think there is a LayerData per se. I assume the references were:

MohoLayer:Metadata - will be removed from the API in a future release as AS11 now has ScriptData
MohoLayer:ScriptData - Added in version 11 - use this and not MetaData
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
synthsin75
Posts: 9981
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Let's suggest new API features

Post by synthsin75 »

hayasidist wrote: Mon Feb 22, 2021 9:40 am
synthsin75 wrote: Sat Feb 20, 2021 7:23 am
Stan wrote: Sat Feb 20, 2021 5:40 am An ability to add custom animation channels. Similar to LayerData, but animatable.
This is probably my #1 request, as it would mean scripts could store animated data for layer script use. Right now I'm repurposing a switch layer AnimString channel, but it would be amazing to add a channel to the layer itself and choose the channel type.
oh yes yes yes ...
but not so much a new API feature more a new core function - extend scriptdata (as implemented for layers) for objects such as shapes, curves, bones ... and now make that an animatable property

e.g. shape:ScriptData:Set("myKeyName", value, frame)
Yeah, I was playing with using *I think* the point color channel in the negative timeline to store boolean (0 or 1) data for each point. Could probably do the same for shapes, bones, etc., but it would be nice to have it built into the API.

But that alone doesn't allow the user to manipulate the keyframes directly. For that, we need custom script animation channels in the timeline.
User avatar
hayasidist
Posts: 3528
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Let's suggest new API features

Post by hayasidist »

synthsin75 wrote: Mon Feb 22, 2021 6:50 pm
hayasidist wrote: Mon Feb 22, 2021 9:40 am oh yes yes yes ...
but not so much a new API feature more a new core function - extend scriptdata (as implemented for layers) for objects such as shapes, curves, bones ... and now make that an animatable property
e.g. shape:ScriptData:Set("myKeyName", value, frame)
But that alone doesn't allow the user to manipulate the keyframes directly. For that, we need custom script animation channels in the timeline.
Agreed completely.

I didn't spell it out, I had visualised that myKeyName was a channel name --- there'd be such as channel = shape:ScriptData(myKeyName) if you needed the AnimChannel; but a lot of the time shape:ScriptData:Set(myKeyName, value, frame) and the equivalent value = shape:ScriptData:Get(myKeyName, frame) would probably do.

Diving deeper, as with scriptdata today, the type of "value" [e.g. LUA type(value)] determines whether it's AnimString, AnimBool etc ..

(and arguably, it would make sense to have those Set and Get functions map more clearly to channel:SetValue() and channel:GetValue() ... rather than to the current ScriptData:Set() and ScriptData:Get<type>() functions)
User avatar
KuzKuz
Posts: 483
Joined: Mon Aug 19, 2013 5:12 pm
Location: Ukraine

Re: Let's suggest new API features

Post by KuzKuz »

Also, it would be nice to have a method to refresh the GPU cached layers. There is a big problem with multilayer scripts. If you make changes on cached layers using the API, the cached layers do not recognize that something was changed, and the cache will not be updated.
User avatar
Mike Roberts
Posts: 85
Joined: Tue Sep 22, 2015 10:40 pm

Re: Let's suggest new API features

Post by Mike Roberts »

**EDIT - sorry this is a feature request not an API - never mind - mods can erase if needed


My biggest wants are mirroring the actions on the rigs - so what you do on one side can be mirrored easily to the other. Do a head turn - copy/paste in reverse on the other side.

Another huge one would be a way to combine smart actions bones so that you can do things like make sure the head turn and - say - a blink - don't conflict. I think there's a script for this that works like a charm.
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Re: Let's suggest new API features

Post by chucky »

Mike Roberts wrote: Fri Feb 26, 2021 1:41 am **EDIT - sorry this is a feature request not an API - never mind - mods can erase if needed


My biggest wants are mirroring the actions on the rigs - so what you do on one side can be mirrored easily to the other. Do a head turn - copy/paste in reverse on the other side.

Another huge one would be a way to combine smart actions bones so that you can do things like make sure the head turn and - say - a blink - don't conflict. I think there's a script for this that works like a charm.
Hey Mike,
for the moment there are a few scripts that can do those things,.
One is for bone actions like walk cycles, Mike Kelly's swiss army bone's tool. I LOVE That one, it does so much more than flipping.
Another is a point flipper/ mirror , I think that's dkwroot's.
And the action modifier, is by Mult Rush.

I don't know where they all reside I normally harvest these scripts and totally forget where they come from, so I agree that they would be really great as built in features.
Maybe put those suggestions in that 'private' place? :wink:
That would be awesome , I'm sure a lot of people have made so many requests that they feel they've said enough for the moment. :oops:
So your contribution would be a relief, I'm sure. :D
Last edited by chucky on Fri Feb 26, 2021 8:30 am, edited 1 time in total.
User avatar
Mike Roberts
Posts: 85
Joined: Tue Sep 22, 2015 10:40 pm

Re: Let's suggest new API features

Post by Mike Roberts »

Ah. This is great in the meantime, thank you! And yes. Will repost somewhere more appropriate!
User avatar
Greenlaw
Posts: 9270
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Let's suggest new API features

Post by Greenlaw »

Somewhat related is DKW Root's Swap Sides script, part of his collection found here...

http://www.lostmarble.com/forum/viewtop ... es#p162626

To use it, you pick a 'reflection' point in the curve, run the script, and it reshapes the curve into a mirror of the of the original curve shape. This is different from merely flipping the shape because it's actually preserving the construction of the curve and it's moving the points to create a reflection. This is incredibly useful, for example, when you need to morph a head shape from one side view to the other.

Practically speaking, you would start with a front view, make your side view on another frame, copy the side view points to another frame, and then run the script. This workflow give you the perfect morph animation from front view to either side views very easily and quickly.

Note that the script isn't perfect. Depending on your shape and the point placement, and if you are using Bezier points, the tool can produce unpredictable results. But if you're aware of the limitations and can work within them, Swap Sides works well enough that you'll want to use it often. (I use it all the time to create smoothly turning heads and torso animations for SBD Actions.)

Another note: the package comes with a companion script called Mirror. This tool will similarly but, instead of mirroring the entire path, it mirrors the right half of the curve to the left half, making a symmetrically shaped curve. (Same limitations apply.)
User avatar
SimplSam
Posts: 1048
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: Let's suggest new API features

Post by SimplSam »

Expressions

I would love to see some form of expression calculations for the configurable UI value fields of objects in Moho, where their value is based on anything accessible & calculable in Moho script. Plus the addition of some helper variables and functions to simplify common expressions.

I think this would open up a whole new world of possibilities for Moho.

Arguably - some of this could currently be done in Layer script, but I would consider such layer scripting to be quite clunky & heavy and nowhere near as lightweight, intuitive, organic and flexible as expressions could be.

The Advanced dialog - would be more like a running a simplified (due to helper features) layer script in a Value field.

Image
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
SimplSam
Posts: 1048
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: Let's suggest new API features

Post by SimplSam »

Modifier keys

Something else that would be welcomed is if modifier keys were recognised when the tool button was invoked. Even extending to recognising Right Click.

This would allow for options like settings mode and advanced mode etc etc..
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
Post Reply