Ann: Script Tutorial in the making - Break off script

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
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 8:30 am
Location: The Netherlands

Ann: Script Tutorial in the making - Break off script

Post by Rasheed »

At the moment, if you have a compound shape that exists of two shapes "glued" together and you want to separate those shapes, you'll have to take a lot of steps, as the figure below illustrates:
Image

We really want to take only two steps:
a. select the shape you want to break off
b. execute some script to separate the compound shape into two shapes

At the moment, you'll have to take these steps:
1. copy the style of the shape you want to break off
2a. select the points of this shape
3a. copy and past the curve
4a. fill the curve, to create a shape
5a. paste the style from step 1 to this new shape
2b. delete the first connecting line segment
3b. delete the second connecting line segment
4b. select the points of the now separate curve
5b. delete the separate curve

That is a lot of steps, which takes a lot of time. It would be nice if we had some menu script to do only steps a and b. Now, that is just the plan for the new script we are going to write.

The user has selected the points of a curve which have to be converted into a separate curve and then the script has to sort out the rest and create two separate shapes. Of course, the script has to be intelligent enough not to delete all the selected points, but rather follow a recipe like in the steps 1, 2a-5a, 2b-5b.

I will not go into the script any further. I just wanted to let you know what I was preparing as a new tutorial for the Scripting forum.

Edit: I changed the title of this post, because it is really an announcement, not the actual tutorial. I think I'll create a Lua section in my homespace and put some general Lua and Moho scripting theory in there as well. That will save LM some bandwidth.
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 8:30 am
Location: The Netherlands

Re: Ann: Script Tutorial in the making - Break off script

Post by Rasheed »

Rasheed wrote:I think I'll create a Lua section in my homespace and put some general Lua and Moho scripting theory in there as well. That will save LM some bandwidth.
OTOH Using FireFox 1.5, I copied the forum text from the Dissecting a Menu Tool: Draw Triangle into the (free) website authoring tool NVU and I almost had to make no changes (well, I had to create a style sheet with the code class definition and copy the images to my webspace). That is so cool and saves so much time, that I want to do this for this article as well. So my plans have changed slightly. I will post the article in parts in this forum and when it is finished, I will put a copy in my homespace.

You can check out the Lua Scripting page in my webspace here:
Lua Scripting for Moho
___
René
Post Reply