Styles

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

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
hayasidist
Posts: 3526
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Styles

Post by hayasidist »

ggoblin wrote: Wed Jun 08, 2022 11:16 pm
How about if you use striders script to replace the new style with a previously UI created old style and then discard the new 'doggy' style and just customise the old style as needed?
If I understand the script correctly - "replace styles" changes the style associated with shapes -- so both the old and new should already exist in the document.... and

if there are styles created by the Moho UI, these can be modified programmatically, but only within the limits of the scripting API - which I think means NOT being able to set Gradient (all variants), Image, Crayon and the legacy effects; and not having ready access to the specific data relevant to each effect type.
ggoblin wrote: Wed Jun 08, 2022 10:50 pm Forgot to mention he uses RelinkStyles. I've never come across that before, there doesn't appear to be any documentation for it.
It's there (I think) to try to sort out the UUID clash when you have two styles with different names but with the same UUID -- many ways this can happen. This was a discussion at the time:

viewtopic.php?t=31433
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Re: Styles

Post by ggoblin »

hayasidist wrote: Thu Jun 09, 2022 7:35 am
plenty of ways to address that...

e.g. in your tool create a list of all the styles in the document and present that list against the list of all the different things you want to create. Exactly how you design that UI is down to you - but (e.g.) you loop through the "things" and present the styles list each time as a dropdown - the user picks the one they want from the dropdown ... or radio buttons against the style list ... or loop through the styles and ask which "thing" to use it for ... but however you do it, you end up with a list of "things" and the chosen style. Setting a style is ok - changing the style on a shape is ok - creating one from "scratch" is the problem right now.
Thank you Hayasidist, I created a dropdown to choose the style for the shapes and it works fine, seems stable so far. This workaround will do for my immediate needs (although it would have been nice to have created some default preset styles in the script as starting points for user customisation). Thank you.

I misunderstood. When I asked how broken the style api was (http://www.lostmarble.com/forum/viewtop ... 58#p205258) and didn't see a direct reply, and then I read posts of how unstable things become even when they appear to work in the script they crash moho later in the ui style pallete, I assumed the worst - that the whole style api was unstable and best avoided. Thats why I posted links to stryders script as he seemed to be using the api without problem even though he was not creating new styles. Glad to know the whole styles api is not broken.
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Re: Styles

Post by ggoblin »

hayasidist wrote: Thu Jun 09, 2022 9:24 am
ggoblin wrote: Wed Jun 08, 2022 10:50 pm Forgot to mention he uses RelinkStyles. I've never come across that before, there doesn't appear to be any documentation for it.
It's there (I think) to try to sort out the UUID clash when you have two styles with different names but with the same UUID -- many ways this can happen. This was a discussion at the time:

viewtopic.php?t=31433
For good measure I included RelinkStyles in my code.. didn't seem to do any harm so left it in. :D
User avatar
hayasidist
Posts: 3526
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Styles

Post by hayasidist »

ggoblin wrote: Fri Jun 10, 2022 2:28 am Thank you Hayasidist, I created a dropdown to choose the style for the shapes and it works fine, seems stable so far. This workaround will do for my immediate needs (although it would have been nice to have created some default preset styles in the script as starting points for user customisation). Thank you.
glad you've got something working! Happy to have helped (as you've probably gathered, this "styles" issue has been an irritation for me, and many others, for several years!) I'm optimistic that the new owners of Moho (headed up by its original creator) have a better approach than the previous owners to providing software that the user-base actually needs! http://www.lostmarble.com/forum/viewtopic.php?t=33643


ggoblin wrote: Fri Jun 10, 2022 2:28 am I misunderstood. When I asked how broken the style api was (http://www.lostmarble.com/forum/viewtop ... 58#p205258) and didn't see a direct reply, and then I read posts of how unstable things become even when they appear to work in the script they crash moho later in the ui style pallete, I assumed the worst - that the whole style api was unstable and best avoided. Thats why I posted links to stryders script as he seemed to be using the api without problem even though he was not creating new styles. Glad to know the whole styles api is not broken.
yeah - I was halfway through replying when I had the idea about NewShapeProperties() which, had it worked, would've changed the answers... and I think you've now got all the answers, albeit scattered across posts. but:

1. Can we safely create a new style from Lua? - NO
2. Can we safely modify an existing style and save it as a new style from Lua? - NO
3. Can we safely modify an existing style in Lua and the modifications appear in the style pallette? Yes - but not all properties
4. Can we safely choose an existing style and use it in Lua for shapes created in Lua? Yes

Are there other known parts of the API that are known to be broken? A list would be very useful. Not so much broken, more "just not there". The ones I know about are: You can't set effect types - Gradient (all variants), Image, Crayon and the legacy effects; there is no ready access to the specific data relevant to each effect type; and you can't change (e.g.) the number of stops in a gradient.
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Re: Styles

Post by ggoblin »

Thank you, much appreciated.
hayasidist wrote: Fri Jun 10, 2022 9:19 am I'm optimistic that the new owners of Moho (headed up by its original creator) have a better approach than the previous owners to providing software that the user-base actually needs!
Different users have different needs and expectations of the software.

Professional animators are using Moho solely for 2d character animation as its the best software for that. They have a suit of other software they can leverage for all other apsects of animation and production where those software excel.

One person teams creating animations for social media, etc. don't always have that luxury or skill set, and are relying on Moho as a one stop animation solution all for their needs. They do not need the very best software in any one specific area, but they need something that is competent in a wide range of applications and has a simple, fast workflow they can leverage to produce animations quickly on their own.

I think at one stage Moho managed both, but over the years, with heavy competition on its heels, it has focused just on what it excels at - character animation. This worries me, I am not hopeful that things like the text engine, the particle system, sound and video handling, basic 3d etc. which are bread an butter needs for social media projects, will ever be updated. I had hoped that maybe through the API it might be possible to extend Moho where needed, but I see now that the API is more limited than I had imagined.

I think the new owners need to share with us their road map of their plans for Moho so then we all know where we stand.
yeah - I was halfway through replying when I had the idea about NewShapeProperties() which, had it worked, would've changed the answers... and I think you've now got all the answers, albeit scattered across posts. but:

1. Can we safely create a new style from Lua? - NO
2. Can we safely modify an existing style and save it as a new style from Lua? - NO
3. Can we safely modify an existing style in Lua and the modifications appear in the style pallette? Yes - but not all properties
4. Can we safely choose an existing style and use it in Lua for shapes created in Lua? Yes
I wasn't sure about 3), so I tried it and it works :)

Code: Select all

			-- to change style in pallete from lua
			local mystyle = moho.document:Style("my style")
			local mycol = LM.rgb_color:new_local()
			mycol.r = 0; mycol.g = 255; mycol.b = 0; mycol.a = 255
			mystyle.fFillCol:SetValue(0, mycol)
Are there other known parts of the API that are known to be broken? A list would be very useful. Not so much broken, more "just not there". The ones I know about are: You can't set effect types - Gradient (all variants), Image, Crayon and the legacy effects; there is no ready access to the specific data relevant to each effect type; and you can't change (e.g.) the number of stops in a gradient.
Missing is not as bad as broken, at least we wont be banging our heads wondering why our code doen't work :)

What about the rest of the API, any know boken parts not related to styles?
User avatar
hayasidist
Posts: 3526
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Styles

Post by hayasidist »

ggoblin wrote: Sat Jun 11, 2022 6:40 am What about the rest of the API, any know boken parts not related to styles?
There's a handful of enhancement requests and a couple of "undocumented" features, but nothing that I know about is so broken to make it unusable ... which is not to offer a guarantee that there aren't any bugs - just that they haven't been found yet! So if you find one, shout out!
Post Reply