New tool: Adjust Line Width (by Stan)

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
Stan
Posts: 199
Joined: Sun Apr 19, 2009 3:22 pm

New tool: Adjust Line Width (by Stan)

Post by Stan »

Image

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).

Download here: http://mohoscripts.com/script/sz_adjust_line_width
Last edited by Stan on Sun Dec 27, 2020 6:41 am, edited 1 time in total.
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
velu
Posts: 47
Joined: Sun Jun 22, 2008 10:52 am
Location: India - Chennai
Contact:

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

Post by velu »

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

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

Post by funksmaname »

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 »

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: 199
Joined: Sun Apr 19, 2009 3:22 pm

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

Post by Stan »

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.
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

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

Post by hayasidist »

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: 199
Joined: Sun Apr 19, 2009 3:22 pm

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

Post by Stan »

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 )?
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

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

Post by hayasidist »

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: 2849
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

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

Post by DK »

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: 386
Joined: Tue Apr 07, 2009 1:00 pm
Location: USA
Contact:

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

Post by uncle808us »

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: 199
Joined: Sun Apr 19, 2009 3:22 pm

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

Post by Stan »

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.
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
User avatar
Greenlaw
Posts: 9192
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

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

Post by Greenlaw »

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
Post Reply