New tool: Adjust Line Width (by Stan)

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
Stan
Posts: 121
Joined: Sun Apr 19, 2009 3:22 pm
Contact:

New tool: Adjust Line Width (by Stan)

Post by Stan » Mon Nov 14, 2016 2:25 pm

Image

The tool allows to adjust the line width by adding/subtracting a value or by multiplying/dividing by a provided coefficient.
It works for the entire selected layer(s), and supports vector layers and all types of group layers (including switch, bone, etc.) with any nesting depth.

Works with Moho 12 (and should work with previous versions, but it wasn't tested).

Image

Download link: http://mohoscripting.com/uploads/1/sz_a ... _width.zip
________________________________________________________________________
http://mohoscripting.com/ - Unofficial Moho (Anime Studio) Lua Scripting Documentation
http://2danimator.ru/ - Russian Anime Studio Forum
velu
Posts: 38
Joined: Sun Jun 22, 2008 10:52 am
Location: India - Chennai
Contact:

Re: New tool: Adjust Line Width (by Stan)

Post by velu » Wed Nov 16, 2016 5:24 am

Is there possible to change the line width and stroke show/hide as changing the width percentage?
I love Anime Studio
funksmaname
Posts: 3107
Joined: Tue May 29, 2007 11:31 am
Location: Nelson, New Zealand

Re: New tool: Adjust Line Width (by Stan)

Post by funksmaname » Wed Nov 16, 2016 10:48 pm

Awesome, this could be useful for scaling... thanks Stan! :)
GaryC
Posts: 53
Joined: Tue Feb 03, 2015 1:02 pm

Re: New tool: Adjust Line Width (by Stan)

Post by GaryC » Wed Nov 30, 2016 2:02 pm

There is a small changed needed to get this working in version 11.

You use "LM.GUI:Divider(true)" a few times when building the layout. In version 11 this raises an error about the first argument not being a boolean.
It expects you to use "LM.GUI.Divider(true)" instead. When I made that change it worked fine. (on lines 87, 102, 113 and 120)

I quickly tested using LM.GUI.Divider in 12 and it seems to work fine there, so I'm not sure if there's a downside to calling it that way.
Stan
Posts: 121
Joined: Sun Apr 19, 2009 3:22 pm
Contact:

Re: New tool: Adjust Line Width (by Stan)

Post by Stan » Fri Dec 02, 2016 5:11 am

Thank you GaryC! I always forget that module functions are used with a dot, not colon. Good catch!

The URL in the first post is updated.
________________________________________________________________________
http://mohoscripting.com/ - Unofficial Moho (Anime Studio) Lua Scripting Documentation
http://2danimator.ru/ - Russian Anime Studio Forum
hayasidist
Posts: 2122
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: New tool: Adjust Line Width (by Stan)

Post by hayasidist » Tue Dec 06, 2016 5:09 pm

Hi Stan - great tool (and I love the way you've handled localisation!! отлично!) A really useful enhancement to this would be to have an option to set the line width at each point to 100% and have the default stroke width altered accordingly (e.g. if I have a shape where the default line width is 20, and I scale down to 20% of that it would be useful to have the default stroke width set to 4 and the point widths at 100%) Is that feasible?
Stan
Posts: 121
Joined: Sun Apr 19, 2009 3:22 pm
Contact:

Re: New tool: Adjust Line Width (by Stan)

Post by Stan » Wed Dec 07, 2016 4:43 am

hayasidist wrote:Hi Stan - great tool (and I love the way you've handled localisation!! отлично!)
Thank you! I came up with that approach a couple years ago, and now all my scripts use that localization method. It would not just automatically translate the script's UI to Russian, but also makes it easy to translate to other languages as well. And it should be pretty fast too (performance-wise).
hayasidist wrote:A really useful enhancement to this would be to have an option to set the line width at each point to 100% and have the default stroke width altered accordingly (e.g. if I have a shape where the default line width is 20, and I scale down to 20% of that it would be useful to have the default stroke width set to 4 and the point widths at 100%) Is that feasible?
So, are you asking about modifying the shape's style line width instead of the point's one? I think that can be done, but I don't think it should be done within this script. Maybe another tool, or menu script? Or maybe I didn't understand your question correctly and you can add some clarifications (like pictures, or, knowing you, some code examples, maybe :D )?
________________________________________________________________________
http://mohoscripting.com/ - Unofficial Moho (Anime Studio) Lua Scripting Documentation
http://2danimator.ru/ - Russian Anime Studio Forum
hayasidist
Posts: 2122
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: New tool: Adjust Line Width (by Stan)

Post by hayasidist » Sun Dec 11, 2016 1:42 am

Yes - I was thinking shape but also setting all point width to 100% - so really a bit of both.

So in meta code

Code: Select all

Get desired stroke width 
For each layer
  For each shape
     Set stroke width
  End
  For each point
    Set point width = 100%
  End
End
User avatar
DK
Posts: 2413
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: New tool: Adjust Line Width (by Stan)

Post by DK » Wed May 23, 2018 9:59 am

Stan. Thank you so much for this script. :D It has saved me hours of work manually adjusting line sizes on several characters to fit into background art. It should be built into the program b y the dev team at SM.

Cheers
D.K
User avatar
uncle808us
Posts: 248
Joined: Tue Apr 07, 2009 1:00 pm
Location: USA
Contact:

Re: New tool: Adjust Line Width (by Stan)

Post by uncle808us » Wed Jun 12, 2019 4:46 pm

How do you install this on a MacBook Pro OSX El Capitan Ver 10.11.6
Anime Studio Pro Ver.11.2.1
Thank you
I use a MacBook Pro, and Anime Studio Pro 11.2
http://uncle808s.blogspot.com
Stan
Posts: 121
Joined: Sun Apr 19, 2009 3:22 pm
Contact:

Re: New tool: Adjust Line Width (by Stan)

Post by Stan » Wed Jun 12, 2019 5:29 pm

Sorry, I don't know anything about Macs, never used them. I can guess if you have the Content Folder you can just put the .lua and .png files into the scripts > tool folder there. Maybe someone with Mac experience will have a better answer.
________________________________________________________________________
http://mohoscripting.com/ - Unofficial Moho (Anime Studio) Lua Scripting Documentation
http://2danimator.ru/ - Russian Anime Studio Forum
User avatar
Greenlaw
Posts: 4383
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: New tool: Adjust Line Width (by Stan)

Post by Greenlaw » Wed Jun 12, 2019 9:31 pm

This might help: there's a basic walkthrough for installing a script in Moho in my 'Introduction to Layer Shortcuts' video. This info should be the same for ASP 11. The video features Windows but the procedure should be the same for Mac, the only difference being the path you chose when you set up the content folder. If you haven't set a content folder yet, you can do that from the Preferences window.

The video is here:

viewtopic.php?f=9&t=32882&p=187802&hili ... ts#p187802
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
Post Reply