Adding shape style with script

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
meix
Posts: 13
Joined: Thu Oct 30, 2008 2:29 pm
Location: Estonia
Contact:

Adding shape style with script

Post 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?
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Adding shape style with script

Post 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.
Last edited by synthsin75 on Tue Dec 17, 2019 11:22 pm, edited 1 time in total.
User avatar
meix
Posts: 13
Joined: Thu Oct 30, 2008 2:29 pm
Location: Estonia
Contact:

Re: Adding shape style with script

Post 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.
User avatar
meix
Posts: 13
Joined: Thu Oct 30, 2008 2:29 pm
Location: Estonia
Contact:

Re: Adding shape style with script

Post by meix »

Not speaking of that selling a product with broken features is kind of cheating. These should be fixed or removed entirely. :)
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Adding shape style with script

Post 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...
Post Reply