Align closed shapes by X or Y

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Align closed shapes by X or Y

Post by Genete »

Hi!
I'm proud to present you a pair of handy scripts that align selected shapes by its gravity center X or Y values.

The file:

http://www.darthfurby.com/genete/Scripting/align.zip

Installation:
Unzip the file and drop the content to the folder:
/home/UserName/AnimeStudio/scripts/tools
(or what other folder where you have installed AS.)

AND BE SURE that you modify the _tool_list.txt file ADDING those two lines at the Draw section. (You can add them to the "Other" section if you want or other different)

Code: Select all

button	ge_alignx		...
button	ge_aligny		...
Replace the tree dots with a letter in capitals if you want to use them by a hot key. But I think ALL the keys are already used by other tools...

To select multiple shapes at the same time you MUST use fazek's select points tools (again fazek's wonderful tools)

Usage:

Select more than one shape at the same time and press the corresponding button.
The shapes will be aligned to the first more deep shape in the layer. So if you want to align TO an specific shape you have to be sure to send it below all the other shapes to be aligned.


For the moment it only work for filled shapes. I have to modify them to be used by only outline shapes.
If a non filled shape is selected it returns an error.

Hope you find these tools useful. And please test them and tell me if you find any bug.

-G
Last edited by Genete on Tue Jul 10, 2007 9:50 pm, edited 1 time in total.
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Yeeehaaaa!

About time someone created this script!

-vern
User avatar
Víctor Paredes
Site Admin
Posts: 5658
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Post by Víctor Paredes »

excellent. thanks genete!



ps. i didn't know that fazek's select points tool could select shapes too. and several shapes.
for what another things its useful to select several shapes?
at the moment, i can't paint several shapes in one time. i have selected several shapes and it just paint one of them.
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

heyvern wrote:Yeeehaaaa!

About time someone created this script!

-vern
Who, where, when, how....? :shock: :shock: :shock:
I haven't found it yet. ... Please let me know to not duplicate efforts!!
selgin wrote:ps. i didn't know that fazek's select points tool could select shapes too. and several shapes.
for what another things its useful to select several shapes?
at the moment, i can't paint several shapes in one time. i have selected several shapes and it just paint one of them.
That's something I've asked me since I installed fazek tools. It should be something that hi prepared when modify the others tools...

I'm glad you like them.
Do you think I should add the non filled shapes also? And what about to align by its boundaries?
-G
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Who, where, when, how....? :shock: :shock: :shock:
There is no script like this. It is a figure of speech.

I meant it time that someone DID create this NOW.


-vern
User avatar
Víctor Paredes
Site Admin
Posts: 5658
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Post by Víctor Paredes »

Genete wrote:Do you think I should add the non filled shapes also? And what about to align by its boundaries?
-G
absolutely.
is there a way to align each line, closed or not? i think it would be a great improvement if it could to align everything selected.
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

heyvern wrote:
Who, where, when, how....? :shock: :shock: :shock:
There is no script like this. It is a figure of speech.

I meant it time that someone DID create this NOW.


-vern
Aaah I got it!

About time! === At last!
In spanish: Por fin!

Haha Thanks Vern. Annotate one more in your English lessons... :D
selgin wrote:is there a way to align each line, closed or not? i think it would be a great improvement if it could to align everything selected.
Yes it is. Only the script have to tweak a little more when the shape is not closed.

But does it makes sense to align the shapes by its rights /lefts /tops /bottoms side points ? It would not be very difficult. It is only other function to the one that calculates the displacement. But the problem is that there would be a lot of buttons, not?
It could be cool that the tool palette change when select a main tool or type of layer. I mean, not only make available or not some buttons, even hide or show them... Like Gimp does when you select a main tool. The palette options change dynamically to offer the proper ones to the current selected tool.
For instance the align buttons should be shown only when the select points tool is selected.
Now the palette is getting so large...

-G
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Please reload the zip file of the initial post.
I have updated the lua files. Now the buttons are not enabled if not possible align the shapes (it is not a vector layer and there are not enough shapes selected)

-G
User avatar
JimmyC
Posts: 158
Joined: Thu Jul 05, 2007 5:10 pm
Location: UK

Post by JimmyC »

I can't get the Align X/Y scripts to work at all. I have the lua files in the tools folder, and I added the buttons to the list. The buttons appear, but are always greyed out, not matter how many filled shapes I select (using Fazek's Select Points/Bones tool)

I have 3 shapes, filled with different colours, one square and two circles, all at different positions on the X and Y axis. I select using Fazek's tool, but the buttins remain greyed out.

It is probably something I am doing :) What am I doing wrong??

Thanks
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

I've just reloaded the current link to align.zip file, extracted the files to a folder, copy and paste to scripts/tools folder (saying yes to replace the same files on my folder) and start again Anime Studio.
They work perfectly.
I don't have idea what's happening with your copy. Please try to reload it again.
I have no hotkey assigned to the buttons tool.

Did you made the followings entries into the _tool_list.txt file?:

Code: Select all

button	ge_alignx		    ...
button	ge_aligny		    ...
This is my _tool_list.txt file. Maybe it helps:

Code: Select all

group Draw
color	204 220 232 255

tool	fa_select_points	G
tool	fa_translate_points	T
tool	fa_scale_points		S
tool	fa_rotate_points	R

tool	fa_add_point		A
tool	lm_delete_edge		D
tool	fa_curvature		C
tool	fa_magnet		    X

tool	fa_freehand		    F
tool	lm_rectangle		E
tool	lm_oval			    L
tool	lm_arrow		    ...

tool	lm_shear_points_x	...
tool	lm_shear_points_y	...
tool	lm_perspective_points_h	...
tool	lm_perspective_points_v	...

tool	lm_bend_points_h	...
tool	lm_bend_points_v	...
tool	lm_noise		    N
tool	fa_replace_line		...

tool	fa_polygon		    ...
tool	cc_sf_MegaMagnet	...
button	ge_alignx		    ...
button	ge_aligny		    ...

button	lm_smooth			M
button	lm_peak				P
button	lm_flip_points_h	...
button	lm_flip_points_v	...

group Fill
color	232 220 204 255
tool	lm_select_shape		Q
tool	fa_create_shape		U
tool	lm_paint_bucket		...
tool	lm_delete_shape		...
tool	lm_line_width		W
tool	lm_hide_edge		H
button	lm_lower_shape		...
button	lm_raise_shape		...

group Bone
color	204 220 232 255
tool	lm_select_bone		B
tool	lm_translate_bone	T
tool	lm_scale_bone		S
tool	lm_rotate_bone		R
tool	lm_add_bone		A
tool	lm_reparent_bone	P
tool	lm_bone_strength	...
tool	lm_manipulate_bones	Z
tool	lm_bind_layer		...
tool	fa_bind_points		I
tool	lm_offset_bone		...
button	ge_uname_bones		U

group Layer
color	232 220 204 255
tool	lm_translate_layer	1
tool	lm_scale_layer		2
tool	lm_rotate_layer		3
tool	lm_set_origin		0
tool	lm_rotate_layer_x	...
tool	lm_rotate_layer_y	...
tool	lm_shear_layer_x	...
tool	lm_shear_layer_y	...

button	lm_flip_layer_h		...
button	lm_flip_layer_v		...

tool	lm_switch_layer		...
tool	lm_particle_layer	...

group Camera
color	233 201 201 255
tool	lm_track_camera		4
tool	lm_zoom_camera		5
tool	lm_roll_camera		6
tool	lm_pantilt_camera	7

group Workspace
color	212 238 212 255
tool	lm_pan_workspace	...
tool	lm_zoom_workspace	...
tool	lm_rotate_workspace	8
tool	lm_orbit_workspace	9

group Other
button	DR_select_parent_layer	J
tool	st_key_none	...
tool	lm_translate_points		Y
button  ge_select_released_points ...
button  ge_select_flexibound_points ...	
button  ge_select_bound_points ...
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Here a sample usage:

http://www.darthfurby.com/genete/Scripting/align.htm (flash screen capture made with wink)

I have no idea what's happening to your version, JimmyC.

-G
User avatar
JimmyC
Posts: 158
Joined: Thu Jul 05, 2007 5:10 pm
Location: UK

Post by JimmyC »

Thanks for taking the trouble G. The Wink file shows it all

I see now what Iwas doing wrong. I was selecting the shapes by drawing a lassoo around them, I now see that they have to be selected individually. Doh! I thought I had to hold down the Shift key too in Fazek's tool, but that is not necessary.

Works fine now. Thank you very much.
Post Reply