Split Layer Script - split shapes on multiple layers

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Split Layer Script - split shapes on multiple layers

Post by heyvern »

Some of you may have noticed in the videos for AS Physics feature that there is a sort of "magic" bit that gets skipped over when drawing a bunch of shapes on one layer and then running physics with each shape on multiple layers.

I created a custom script to make this easier.

Split Layer Script

------------
Two ways to install the script:

AS Pro and Debut installation:

Put this script in the scripts/tool/ folder and add this line to your _tool_list.txt file as shown below:

Code: Select all

button	hv_split_layer		...
I don't have a icon for it yet. It will show up in your tool palette as a "?" in the spot you paste that line your _tool_list.txt file. You MUST add this line to the _tool_list.txt file. The script will only work as a button.

This will work with Debut. I know Debut does not have physics but this script might be useful for other purposes.

----------------------------------------

AS Pro only Menu Script installation:

Install in scripts/menu/

Select the script from the scripts menu in AS.

--------------------------------------

Instructions:

Run on a vector layer inside a group layer that has physics turned on.

This script ONLY works on vector layers with ALL CLOSED VECTOR SHAPES. Each shape must be a single closed vector to work properly. I hope to improve this later for other uses.

Once your layer is ready to "split" make sure all of the physics properties are set in this layer FIRST so that the split layers have those physics settings.

Click the tool button (or select the menu script if installed that way). The script will create one layer for each separate shape.

At the bottom of the newly created layers there will be the original layer with all the shapes which should be moved outside of the physics group layer. There is also an empty "template" layer. It will have the name of the original layer with "-Template" added on. Delete this layer. This is a blank template layer created by the script to duplicate for pasting in the shapes so all of them have the same physics settings. Unfortunately there is no way to delete or remove layers using the script interface so this has to be done by hand.

Make sure you keep the original layer after moving it out of the group layer so you can run the script again if needed.


-vern
User avatar
bibendumchamalow
Posts: 23
Joined: Mon Jul 05, 2021 9:15 pm

Re: Split Layer Script - split shapes on multiple layers

Post by bibendumchamalow »

Hello Vern, how are you?
I was researching a script for Moho to allow me to separate the shapes of a layer into separate layers and I came across your post.
I tried to download the script you posted. unfortunately the link is broken.
Is it possible to post it again. Or can you advise me a trick ;-p
Thank you in advance. :D
User avatar
synthsin75
Posts: 9979
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Split Layer Script - split shapes on multiple layers

Post by synthsin75 »

You might also try the stock script found in: Scripts > Layer Effects > RT: Break Apart Shapes.
User avatar
bibendumchamalow
Posts: 23
Joined: Mon Jul 05, 2021 9:15 pm

Re: Split Layer Script - split shapes on multiple layers

Post by bibendumchamalow »

synthsin75 wrote: Wed Aug 31, 2022 12:16 am You might also try the stock script found in: Scripts > Layer Effects > RT: Break Apart Shapes.
Thank you very much for your answer, it works very well.
I hadn't thought of looking in these menus.
Thanks again for your reply. :wink:
Post Reply