File Directory/Data

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
anthonytsb5
Posts: 13
Joined: Mon May 15, 2017 11:51 am

File Directory/Data

Post by anthonytsb5 »

Is there a way to get the name of the file currently being worked on and the directory it is stored in?

I am working on a camera manager so I can just have a series of buttons to switch between camera views and am planning on storing the data in the same location as the file. All the examples I found use localize to save it in the script directory which seems problematic to me if you're ever handing off files.
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: File Directory/Data

Post by synthsin75 »

moho.document:Path()

This will return the current file's complete path name. You can then remove the file name (moho.document:Name()) to find the directory.
anthonytsb5
Posts: 13
Joined: Mon May 15, 2017 11:51 am

Re: File Directory/Data

Post by anthonytsb5 »

Once again you are my personal hero, synthsin75.
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: File Directory/Data

Post by synthsin75 »

Glad to help. :wink:
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: File Directory/Data

Post by hayasidist »

anthonytsb5 wrote:Is there a way to get the name of the file currently being worked on and the directory it is stored in?

I am working on a camera manager so I can just have a series of buttons to switch between camera views and am planning on storing the data in the same location as the file.
synthsin75 wrote:u can then remove the file name (moho.document:Name()) to find the directory.
or simply append something like camera to the end ==> xxx.mohocamera or strip off the moho and replace it ==> xxx.camera

and .. I'd love to see this script when it's finished!
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: File Directory/Data

Post by synthsin75 »

hayasidist wrote:or simply append something like camera to the end ==> xxx.mohocamera or strip off the moho and replace it ==> xxx.camera
Good point. Doesn't matter what the extension is, so long as your script knows the one to accept/look for.
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: File Directory/Data

Post by hayasidist »

a further thought -- if the camera stuff is only for the one project you might like to consider using MohoDoc:Metadata() see http://www.mohoscripting.com/index.php? ... ta&id=1014 rather than a file -- an example of managing such data is in http://www.mohoscripting.com/index.php? ... ta&id=1122
anthonytsb5
Posts: 13
Joined: Mon May 15, 2017 11:51 am

Re: File Directory/Data

Post by anthonytsb5 »

hayasidist wrote:and .. I'd love to see this script when it's finished!
Thanks, hayasidist. One last hurdle on the script but I'm hoping to upload it tonight/tomorrow so folks can take a look at take into into production on a short I'm working on this week.
Post Reply