Moho document library: create folder and move existed imported file into

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
bwolf88
Posts: 3
Joined: Fri Aug 13, 2021 7:06 pm

Moho document library: create folder and move existed imported file into

Post by bwolf88 »

Hi guys !

I want to import some files into moho document and place by defferent categories (folders, for example: Characters, Audio etc.). The problem is: I can't find in scripting references how to create folder in current document library and move imported files into.

So how can I do this ?
Thanks.
User avatar
Víctor Paredes
Site Admin
Posts: 5665
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Re: Moho document library: create folder and move existed imported file into

Post by Víctor Paredes »

I think what you are looking for is in the menu File -> Gather Media...
Image Image Image Image
Moho Product Manager

www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
bwolf88
Posts: 3
Joined: Fri Aug 13, 2021 7:06 pm

Re: Moho document library: create folder and move existed imported file into

Post by bwolf88 »

Víctor Paredes wrote: Mon Aug 23, 2021 5:06 pm I think what you are looking for is in the menu File -> Gather Media...
I didn't quite understand what this functionality does.
What I need is: by scripting, after file importing in document library (image below), creating some category folder in this library (Image, sound, etc.) and put the file reference into this category folder.

For example this "download.jpg" put into [Untitled.moho->Images] folder

Image
User avatar
synthsin75
Posts: 9975
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Moho document library: create folder and move existed imported file into

Post by synthsin75 »

Since there is no scripting access to the Library, Victor's suggestion is probably the closest.

File>Gather Media collects all the referenced files in the document and puts them in Images, Audio, etc. folders with the Moho file.
To speed this up, enable Edit>Preferences>Documents tab>Open and switch to new file after Gather.

Then you can just File>Gather Media and add to the Library.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Moho document library: create folder and move existed imported file into

Post by Greenlaw »

FYI, this issue might be fixed by now but double-check that Moho project file size after Gather isn't unusually huge. If it is, just resave it. If the file size seems correct, never mind. :)

The problem back then was that compression wasn't being applied to the Moho file after Gather; resaving the file compresses it. I think this issue may have gotten fixed but it's been a long time since I last used Gather so I'm not sure. This is more of an issue when you need to send somebody the gathered files, or if you have very limited diskspace.
User avatar
Hoptoad
Posts: 618
Joined: Sun Jan 03, 2016 4:19 pm
Location: Florida

Re: Moho document library: create folder and move existed imported file into

Post by Hoptoad »

I used Gather Media for the first time a couple days ago and it worked like I had expected. It made a new folder, and in that folder was a folder called Audio with the audio files duplicated, a folder called Images with the image files duplicated, the relevant .moho file, and a text file called Bill of Materials which listed all the filed that had been gathered. I had to compress it myself, Moho didn't do that.
User avatar
synthsin75
Posts: 9975
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Moho document library: create folder and move existed imported file into

Post by synthsin75 »

Hoptoad wrote: Mon Aug 23, 2021 8:22 pm I had to compress it myself, Moho didn't do that.
Dennis was talking about the Moho file itself, not the folder of all the assets. A Moho file is already a compressed archive file, containing the JSON Moho file and thumbnail image. If Gather doesn't compress all the whitespace in the JSON, the file can be a lot bigger.


EDIT: Just checked, and Moho still isn't compressing the Moho JSON for Gather. So if you have Moho automatically opening the gathered file, you'll want to immediately save it again to compress the file size.
User avatar
Hoptoad
Posts: 618
Joined: Sun Jan 03, 2016 4:19 pm
Location: Florida

Re: Moho document library: create folder and move existed imported file into

Post by Hoptoad »

Oh, okay. Immediately save, to make a smaller file. Got it. Thanks.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Moho document library: create folder and move existed imported file into

Post by Greenlaw »

Thanks for checking. It was probably one of the things that got fixed in 13.0 and then lost in the 13.5 reboot. I'll report it.
User avatar
synthsin75
Posts: 9975
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Moho document library: create folder and move existed imported file into

Post by synthsin75 »

Greenlaw wrote: Mon Aug 23, 2021 10:46 pm Thanks for checking. It was probably one of the things that got fixed in 13.0 and then lost in the 13.5 reboot. I'll report it.
Although it is nice to have some way to view the uncompressed file, without having to jump through Python to beautify it.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: Moho document library: create folder and move existed imported file into

Post by Greenlaw »

Some 3D and compositing programs I've used give you the option to save compressed or uncompressed, and let you set the default behavior for how it saves.

Maybe Moho can use this feature?
Last edited by Greenlaw on Wed Aug 25, 2021 3:46 pm, edited 1 time in total.
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: Moho document library: create folder and move existed imported file into

Post by davoodice2 »

last lime I use gather media it broken my project. Moho did not know the path of any of the files, even when I was redirecting and saving, and the same thing happened again. Until I had to delete every folder and file I had created in the library to fix the problem.
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
synthsin75
Posts: 9975
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Moho document library: create folder and move existed imported file into

Post by synthsin75 »

davoodice2 wrote: Wed Aug 25, 2021 8:21 am last lime I use gather media it broken my project. Moho did not know the path of any of the files, even when I was redirecting and saving, and the same thing happened again. Until I had to delete every folder and file I had created in the library to fix the problem.
Sounds like user error. May not switching to the gathered file, not moving it by its containing folder, etc..
Post Reply