Edit freehand tool with saved settings?
Moderators: Víctor Paredes, Belgarath, slowtiger
Edit freehand tool with saved settings?
Is it possible to edit the freehand tool like this: ...?
1. tool with settings set to: auto-fill=false, auto-stroke=true, auto-close=false (preferably also have it load the first brush in the brush menu)
2. tool with settings set to: auto-fill=true, auto-stroke=false, auto-close=true (and preferably set fill settings to 'soft edge 20')
I took a look at the code, and it looks like it should be easy (to set the auto-fill etc at least), but I really don't understand lua. (not yet)
I'd love to have these tools, because I need to access these settings all the time, and if they were tools I can shortcut them.
Any help is greatly appreciated! Thanks
1. tool with settings set to: auto-fill=false, auto-stroke=true, auto-close=false (preferably also have it load the first brush in the brush menu)
2. tool with settings set to: auto-fill=true, auto-stroke=false, auto-close=true (and preferably set fill settings to 'soft edge 20')
I took a look at the code, and it looks like it should be easy (to set the auto-fill etc at least), but I really don't understand lua. (not yet)
I'd love to have these tools, because I need to access these settings all the time, and if they were tools I can shortcut them.
Any help is greatly appreciated! Thanks
- hayasidist
- Posts: 3515
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Edit freehand tool with saved settings?
My thoughts on this - please feel free to diasagree or offer other ideas!
the first part - preset tool preferences - is pretty straightforward. The easy way (but not the most elegant) is simply to make a second copy of the tool script and do a global replace of LM_Freehand with (say) LM_Freehand2. Also you'll need to duplicate, reanme and mod the icon (lm_freehand.png to lm_freehand2.png) so you can tel them apart. Then you can set and store different start-up options to your heart's content. To make "permanent" changes to the default start-up options change the settings in LM_Freehand:ResetPrefs() and then reset the tool instance.
Line width is trickier because it looks as though the tool uses the default stroke width for new shapes [moho:NewShapeLineWidth() ], but to override this you have a couple of options: (quick and dirty) hardcode a line width instead of using the moho variable; or (tidier) add menu options to the LM_FreehandDialog to use the default or an input line width.
The more elegant way of selecting sets of presets would also be to mod this dialogue to have choices such as "save the settings as my profile A"; "use the seetings from my profile B" etc etc.
the first part - preset tool preferences - is pretty straightforward. The easy way (but not the most elegant) is simply to make a second copy of the tool script and do a global replace of LM_Freehand with (say) LM_Freehand2. Also you'll need to duplicate, reanme and mod the icon (lm_freehand.png to lm_freehand2.png) so you can tel them apart. Then you can set and store different start-up options to your heart's content. To make "permanent" changes to the default start-up options change the settings in LM_Freehand:ResetPrefs() and then reset the tool instance.
Line width is trickier because it looks as though the tool uses the default stroke width for new shapes [moho:NewShapeLineWidth() ], but to override this you have a couple of options: (quick and dirty) hardcode a line width instead of using the moho variable; or (tidier) add menu options to the LM_FreehandDialog to use the default or an input line width.
The more elegant way of selecting sets of presets would also be to mod this dialogue to have choices such as "save the settings as my profile A"; "use the seetings from my profile B" etc etc.
Re: Edit freehand tool with saved settings?
Thanks this works great!!! Now I've got two tools who both remember their own settings. Cool! A 'freehand stroke' tool and a 'freehand fill' tool.hayasidist wrote:My thoughts on this - please feel free to diasagree or offer other ideas!
the first part - preset tool preferences - is pretty straightforward. The easy way (but not the most elegant) is simply to make a second copy of the tool script and do a global replace of LM_Freehand with (say) LM_Freehand2. Also you'll need to duplicate, reanme and mod the icon (lm_freehand.png to lm_freehand2.png) so you can tel them apart. Then you can set and store different start-up options to your heart's content.
I can't get this to work. I put the settings in LM_Freehand:ResetPrefs(), what do you mean by "reset tool instance"?To make "permanent" changes to the default start-up options change the settings in LM_Freehand:ResetPrefs() and then reset the tool instance.
If I change the settings for the Stroke tool to also do auto-fill, I'd like the auto-fill to be deselected again when I go to the tool again. Right now it remembers the change, so it's not actually a Stroke tool anymore...
Something for the futureLine width is trickier because it looks as though the tool uses the default stroke width for new shapes [moho:NewShapeLineWidth() ], but to override this you have a couple of options: (quick and dirty) hardcode a line width instead of using the moho variable; or (tidier) add menu options to the LM_FreehandDialog to use the default or an input line width.
The more elegant way of selecting sets of presets would also be to mod this dialogue to have choices such as "save the settings as my profile A"; "use the seetings from my profile B" etc etc.
Right now quick and dirty is good enough for me, the animation style is quick and dirty too. (Even quicker if there'd be seperate stroke and fill freehand tools!!!)
Thanks!
- hayasidist
- Posts: 3515
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Edit freehand tool with saved settings?
yes - tool option settings are preserved across invocations. whatever options you've selected are saved when the tool exits by xxx:SavePrefs(prefs); and loaded when the tool (re)starts by xxx:LoadPrefs(prefs). So to stop this, just comment out the options you don't want saved or loaded BUT/AND if you do this you'll need to change the settings in the UI routines (near the end of the script):
...
LM_Freehand.autoClose = false
LM_Freehand.autoFill = true
LM_Freehand.autoOutline = true
...
xxx:ResetPrefs() is the routine called when you click the tool icon in the top left of the screen and select "reset tool". This is what I meant by my idea about "reset" ... so ideally you'll the make values in xxx:ResetPrefs() consistent with the "first run" values in the UI
...
LM_Freehand.autoClose = false
LM_Freehand.autoFill = true
LM_Freehand.autoOutline = true
...
xxx:ResetPrefs() is the routine called when you click the tool icon in the top left of the screen and select "reset tool". This is what I meant by my idea about "reset" ... so ideally you'll the make values in xxx:ResetPrefs() consistent with the "first run" values in the UI
Re: Edit freehand tool with saved settings?
That was a bit too dificult for me, but I just deleted the whole GUI part (as dirty as coding can be I guess)
The tools are perfect that way, thanks so much for your help Hayasidist!
The tools are perfect that way, thanks so much for your help Hayasidist!
- hayasidist
- Posts: 3515
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Edit freehand tool with saved settings?
brutal but effective! glad to have been able to help.Lukas wrote:... I just deleted the whole GUI part (as dirty as coding can be I guess)
- alanthebox
- Posts: 214
- Joined: Sat Feb 03, 2018 5:31 pm
- Contact:
Re: Edit freehand tool with saved settings?
So glad I found this thread! It's awesome having a stroke-only tool/shortcut! My only question is (after duplicating and adjusting the lm_freehand.lua file), is it possible to have this tool appear in the "Draw" tools sidebar next to the original freehand tool, rather than appearing in the "Other" section?
- hayasidist
- Posts: 3515
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Edit freehand tool with saved settings?
Find the tool list file in your custom content folder ...\Moho Pro\scripts\tool\_tool_list.txt COPY IT and save the copy somewhere safe …
then add a line for the filename (without the .lua) where you want it in the list e.g. the new line comes after the original freehand tool's line in the
group MOHO.Localize("/Tools/Group/Draw=Draw")
Save a copy of this edited file somewhere safe too -- it might get wiped out if you reinstall.
then add a line for the filename (without the .lua) where you want it in the list e.g. the new line comes after the original freehand tool's line in the
group MOHO.Localize("/Tools/Group/Draw=Draw")
Code: Select all
tool lm_freehand ...
tool lm_freehand2 ...
- alanthebox
- Posts: 214
- Joined: Sat Feb 03, 2018 5:31 pm
- Contact:
Re: Edit freehand tool with saved settings?
Ahh, thanks for your help! I tried updating the tool list in the custom content folder but didn't see any change. Updating the tool list within the actual main installation directory did the trick, though!