Grab all open documents

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: 3700
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Grab all open documents

Post by hayasidist »

LeviFiction wrote: Wed Jun 22, 2022 7:07 am Thank you again. I've grabbed examples of every style by making a change, saving the mohoproj file, and searching for the styles. I'm still so new to Lua's tables to make up for the lack of classes (not a fan but I'll get over it xD) but I think I've got a decent one set up to help me create accurate json for all style values and combinations. Right now just making sure I've accounted for all mins and maxs (mostly 0-256, or 359 for angles), that the calculations are done right (several are percentages of a weird constant 0.20576153), and legacy colors use 0-255 while new color values are 0-1. Also considering making it understand M_Style tables for quick importing and editing. No idea what I'm going to do with this, xD But I'm committed to see if I can make it work.
angles are typically stored as radians not degrees (if you have an example of not, please say!)

I don't recognise the constant 0.20576153 -- this **might** be something to do with whatever shape / render resolution you're using.. if you want to post / upload (or PM if you feel the info is sensitive) I'll have a poke at it. Notwithstanding, this might help: http://www.lostmarble.com/forum/viewtop ... 33#p204633

There are two Moho colour classes in current use - RGB (0-255) and Vector (0-1) Both are current -- so pedantically RGB is not "legacy"

And finally, just in case: a heads-up: there are document-wide styles; and there are styles "private" to a shape .. they both use M_Style but are stored in different parts of the .mohoproj

Really interested to see how this progresses! :D :D
User avatar
LeviFiction
Posts: 18
Joined: Thu Jul 10, 2014 4:19 am

Re: Grab all open documents

Post by LeviFiction »

Didn't catch they were stored in Radians before posting, did later. XD But it's why I'm double checking everything, changing values, saving, and seeing what the end result is. I'll probably still have the function take degrees and just convert them to radians on the backend. That way creating styles is closer to the UI. When I say "legacy" I'm just referring to the effects that show up under the "Legacy Effects" title in the drop-down list. Though It's handy to know how Moho records these in the API, so again, thank you. :D I'm focusing solely on the document wide styles. As for the silly "constant" I thought I had found. I'm not sure how that all works.

I first noticed it when I created a Shaded effect and set the value of Offset to 100. Looking at the resulting file I got 0.205761. When I changed it to a value of 1 I got 0.002058. Making it a perfect percentage of this value. And it showed up in every style in the same way so I thought it was some kind of internal constant, but I'm obviously wrong there.

It is definitely, as you suggested, based on resolution. EDIT: And now I know how. It's the moho units you mention in your previous post. I should have read your link sooner, I was going to wait until lunch time. Though thankfully I didn't as I might have dismissed it as I didn't realize what resolution my project was set at.

During my initial tests I didn't realize my project was set to 872x486. But 100/486 = 0.2057613
Post Reply