*NEW* Beautify Moho file

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

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

Post Reply
User avatar
synthsin75
Posts: 7113
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

*NEW* Beautify Moho file

Post by synthsin75 » Sun Feb 24, 2019 5:17 am

https://sites.google.com/site/synthsin/ ... ects=0&d=1

This menu script will extract the current Moho file and beautify its formatting to make it easier to read. It will prompt you to save any changes to the file and where to save/what to name the beautified file.

This includes a python script, which requires you to have python installed on your computer.

It has been tested with Python 2.7, which you can find here: https://www.python.org/download/releases/2.7/
User avatar
Greenlaw
Posts: 4386
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: *NEW* Beautify Moho file

Post by Greenlaw » Mon Feb 25, 2019 10:07 am

Thanks, Wes! Will check it out soon!
D.R. Greenlaw
Artist/Partner - Little Green Dog | Little Green Dog Channel on Vimeo | Greenlaw's Demo Reel 2017
Lead Digital Animator, Dreamworks Animation

Image
hayasidist
Posts: 2123
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: *NEW* Beautify Moho file

Post by hayasidist » Mon Feb 25, 2019 9:42 pm

This was not working at all for me. Win 10 / 1803. Other than the prints I've enabled, there were no error messages - it runs but does not produce a .mohoproj

I have the .lua where it should be - and it shows up in the dropdown and seems to work - e.g. it correctly goes through the save / beautify as last saved loop
I enabled a couple of the print lines in the .lua

print (path) correctly identifies the destination .mohoproj
print (message.."python "..util.." extract -b "..file.." "..path) produces what would be expected from the code

the .py is in the script resources directory

I have installed and can invoke python - I can type (e.g.) help / modules and I do get the list of available modules.
====


A bit of detective work and …

replacing python with (in my case) C:\Python27\python.exe works.

The actual code change I made was os.execute("C:\\Python27\\python.exe "..util.." extract -b "..file.." "..path)
User avatar
synthsin75
Posts: 7113
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Beautify Moho file

Post by synthsin75 » Mon Feb 25, 2019 10:10 pm

Huh, I don't remember if the Python installer I used added python to the system path (environment variable) or I did that manually.

You can run this to see if Python is on your system path:
print(os.getenv("PATH"))

If it isn't, I'll see about asking the user to find Python.exe if it's not found on the PATH...when I get the time.
User avatar
synthsin75
Posts: 7113
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Beautify Moho file

Post by synthsin75 » Tue Feb 26, 2019 5:57 am

I've updated this (same link) to ask the user to find python.exe if it's not on the system PATH. If anyone uses this on Mac, it will probably need further updates, but it should be solid on Windows.
hayasidist
Posts: 2123
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: *NEW* Beautify Moho file

Post by hayasidist » Tue Feb 26, 2019 8:47 am

thanks Wes. thinking back about when I installed python, there may well have been something about putting the executable somewhere else or even about path - but I just used the default options in the python installer.
obtusity
Posts: 73
Joined: Tue Jan 12, 2016 2:30 am

Re: *NEW* Beautify Moho file

Post by obtusity » Wed Feb 27, 2019 2:14 am

On Python 2.7 (for Windows) adding the executable to the path was an option, but it was one of those old icons-in-a-tree-structure with a drop-down and "will be installed on local hard drive", and not the default.

In Python 3.x it's a more obvious checkbox, but unlike the rest of the Python install it requires admin approval (a little security speedbump which helps prevent random software adding a folder to the path with, for example, an alternative cmd.exe, notepad.exe, etc).
User avatar
synthsin75
Posts: 7113
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Beautify Moho file

Post by synthsin75 » Wed Feb 27, 2019 2:39 am

Thanks for double checking, obtusity.
Post Reply