Style manager 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
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Style manager script?

Post by heyvern »

Import a Moho object with styles into another Moho file with THE SAME styles... and see what I mean.

Is there a way to "consolidate" styles using LUA?

I just had a new experience... I imported a Moho object into one file... then imported that file into another file...

... the style names got so long (it adds the name of the file along with the layer name to the style name) that the style menu couldn't display them. I had to go through and rename all of the "long" styles before I could use the menu again.

I am looking for something fairly simple. Just replace ALL of one named style reference with another... then I can delete unused styles.

-Vern
User avatar
Fazek
Posts: 246
Joined: Thu Apr 13, 2006 1:37 pm
Location: Hungary
Contact:

Post by Fazek »

I made the same thing and it seems it is not easy, since I don't know how to get the list of the styles in a MohoDoc. So I think it is not possible to edit these things inside MOHO, but maybe it is possible to process the exported document file. It would be great to create a document editor tool, where you can do all of these things, importing, using style palettes etc., maybe from Moho, but working with external files.

Is there an exact description somewhere about the moho document file format?
- - - Fazek
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

UPDATE
-------------

I have not seen a description of the file format per say... but I have through "brute force" kind of figured out where the style information is.

All the styles seem to be "at the top-ish" of the document.

I was able to use a search and replace to change the names of the styles fairly quickly in JEdit (I love this application). Then I opened it again in Moho and deleted the unused styles. (I am not brave enough yet to figure out how to delete actual styles in a text editor).

I did a replace all but started after the style reference and didn't wrap the search so the first use of the style name itself didn't get replaced (otherwise i would have two styles with the same name).

I was able to "fix" a bunch of very "messy" documents in just a few minutes. It is very easy now to make this change outside of Moho.

What I plan to do from now on is just continue working in Moho normally and then do a batch fix every so often when things get "out of hand" so to speak, style-wise.

-Vern
User avatar
Fazek
Posts: 246
Joined: Thu Apr 13, 2006 1:37 pm
Location: Hungary
Contact:

Post by Fazek »

When programming, I am always worrying because I don't know how LM will continue the development. Maybe my tools will be incompatible with the future versions. Some parts of Moho (like the vector layers, and perhaps, bones) are well-defined and they are working good so maybe these conceptions will remain unchanged in the future versions. Others, like accessing some animated channels (curvature, for example) or yes, the styles! I think will be changed. I think the Moho document format would look more editable (XML?), but this is only my opinion.
- - - Fazek
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Fazek,

I agree with you 100% on the "future compatibility" issue with these scripts. I thought about that the first time I started fiddling with a script. I was just a little afraid to mention it. ;)

I thought that there was probably a good chance that some of these scripts may need to be updated at some point down the road.

-------------

Then I thought maybe there will be at least some kind of... transition period...

... similar to Flash Actionscript. When Macromedia would depricate code or change how things worked with a new version... they would leave the "old" in there for a time so people wouldn't have to reinvent the wheel from scratch. (I still use some depricated Actionscript in my Flash stuff... I really should change it).

It would seem to me that leaving in some of the ways of doing things in Moho NOW... would be simple enough even if new improved ways are added.

All the tools and scripts that come with Moho "out of the box" were written the same way.. so if it changes too much... LM will have to update everything as well... so... "they" probably would want to avoid that if possible as well as us.

If anything... I imagine any new version would most likely be MORE exposed... keep the status quo but expose more, new functions to LUA scripting.

I will be keeping my fingers crossed! ;) I predict it will be a while before I need to worry about it.

-Vern
Post Reply