Page 1 of 1

Adding shape style with script

Posted: Mon Dec 16, 2019 9:20 pm
by meix
I'm trying to add shape styles from script with MohoDoc:AddStyle(style) method where style argument should be an instance of M_Style class but I can't figure out how to instantiate M_Style object.
Some object classes of moho have methods like new_local() for that purpose but not M_Style class.
Any ideas?

Re: Adding shape style with script

Posted: Mon Dec 16, 2019 11:47 pm
by synthsin75
That function is basically broken. You can only create a style by copying another or a shape's style (to get M_Style), but it seems to be an instance of the style instead of an independent copy. And if you try to delete a style created with that function, Moho crashes.

If you then save the file and quit Moho, it will crash, but reopening the file then sorts out the new style properly.

Re: Adding shape style with script

Posted: Tue Dec 17, 2019 6:52 am
by meix
Thanks, yes, I tried to make "dummy" style first, then get it with MohoDoc:Style(styleName) or MohoDoc:StyleByID(id) method and use that as argument for MohoDoc:AddStyle(style). New items where actually added to style list but all these were references of original style so editing one would actually reflect in all of them. Because it's pointless and obviously not intended use, scene became unstable, could crash and saving/reopening didn't fix anything, at least for me. Using Moho version 12.
Moho is great, I've used it long time (not regularly though) but I think creating a proper API should have a higher priority for developers. That could give community a chance to extend the product like blender does, where big part of functionality is created by addons developed by users themselves.

Re: Adding shape style with script

Posted: Tue Dec 17, 2019 6:57 am
by meix
Not speaking of that selling a product with broken features is kind of cheating. These should be fixed or removed entirely. :)

Re: Adding shape style with script

Posted: Tue Dec 17, 2019 8:44 am
by hayasidist
FWIW bug reports were raised in 2014 and 2017 relevant to this subject (31984 and 39555). I've asked the (new) dev team to take a look...