Page 1 of 2

Select Shape tool - See where in the order the dang shape is

Posted: Sun Mar 27, 2005 5:08 pm
by 7feet
Anigreator had asked for a "Layer" type window that would show you the shape order in a layer. Which I thought was a good idea. But wasn't quite as far as I wanted to go on a sunday morning, and probably left to LM anyway. So I decided to modify the Select Shape tool to add a box to show you what the number of the shape was in relation to its place in the shape pecking order. Should help keep track of the pesky things. I also modified the Raise and Lower Shape tools slightly so they'll keep the number updated properly.

The other thing I did was to add a bit. If you hold down <CTRL> and <ALT> and use the <UP> and <DOWN> arrow keys you can cycle up and down through the shapes, in depth order, selecting the shapes. This can give you a good idea of the stacking order pretty fast, and maybe help find those entirely hidden shapes without going nuts.

I made these as a straight replacement for the existing tool, so just back up the original ones (I don't think there's any problem with the mod, but it pays to be safe, the file names to look for are lm_select_shape.lua, lm_raise_shape.lua, and lm_lower_shape.lua), and unzip The File in you Moho>Scripts>Tool folder.

Hope that's somewhat useful. I may set it up to be a persistant window (kinda like the Bone Constraints pulldown in the Select Bone tool), but thats for another day. Also, another thing to keep in mind is that if you click on the Shapes button at the top of the Style window, it'll show you the list of shapes in the current layer, with their names and in their proper stacking order. Good for seeing the lay of the land, but I like the instant feedback. Cheers!

--Brian

Posted: Sun Mar 27, 2005 6:26 pm
by anigreator
Great work Brian!

Moho life just became a little easier.

NOTE TO ALL USERS: You have to move/delete the original scripts from your /scripts/tools folder. Simply renaming them will cause the new tools to malfunction (I discovered ;-).

Once again, many thanks!

Posted: Sun Mar 27, 2005 9:03 pm
by LittleFenris
Would there be a way to make the tool actually raise and lower the shapes? Or maybe a seperate tool for this? I hate having to raise the shape, then go back to the menu and do that again and again. If I at least had a keyboard shortcut for that it would be great, but a tool that you could select the shape, then hit the Up and Down keys or something would be sweet.

Posted: Sun Mar 27, 2005 9:26 pm
by anigreator
Which is exactly what this new tool does. :)

Posted: Sun Mar 27, 2005 10:04 pm
by 7feet
Yup. Actually, that part it always did. There was no real good indication that it did do it on the screen when you are using the tool, and the arrow key shortcut info was kinda mixed in inside the help file, not really too well defined. I hadn't even realized it was there, only discovered it by peeking at the script and then went back to the help to search for it. So, the whole instructions, in a nutshell.

Click - you Select a Shape.

Hit <BACKSPACE> or <DELETE> and the currently selected shape goes away.

<ALT> click on a different shape while one is selected and the Style from the selected shape is copied to the one you click on.

<ALT><CTRL> click on a non-selected shape and its style is copied to the selected one.

Hit the Up or Down Arrow keys and the selected shape moves, well, up or down.

Hold <CTRL> while you hit the Arrow keys and you can move through any shapes that are lying under where the mouse is (or more properly where the mouse was the last time you clicked it, I think), even if some of them are completely hidden behind another shape.

Hold <SHIFT> while you work the Arrow keys, and the selected shape is moved to the top or bottom of the order.

Hold <CTRL> and <ALT> while you use the Arrow keys and you run up and down the shapes, in depth order, selecting each one in turn.

Also, keep in mind that the lower numbers that are displayed are towards the bottom, the higher towards the top. Not too hard to figure, but worth mentioning. I'll probably fold in the ability to create shapes if I get the urge. I dig those key combos. But first I want to make a usable bloody eyedropper kinda tool, which banging this out gave me a few ideas on. And a good call on moving the backups somewhere else. Forgot to mention that. Putting a subfolder in the Tools folder and putting the backups there works fine, and keeps 'em nearby in case something blows up. Later.

--Brian

Posted: Mon Mar 28, 2005 1:16 am
by pixelwks
Very very good!

Posted: Fri Jun 29, 2007 11:19 pm
by VĂ­ctor Paredes
wow. i never seen this before. great tool, 7feet.
e-frontier should group all this scripts in a download section. it can't be that nobody know about some scripts just because they where lost in the see of threads.

Posted: Fri Sep 21, 2007 12:44 am
by Rudiger
Yeah, I just rediscovered this tool recently and now couldn't live without it. Brian (7Feet) seems to have disappeared from these Forums so I thought I would post a little enhancement I made to it.

If you paste this message handler into Brian's modified lm_select_shape.lua tool, then you can instantly set the Shape Number of the selected shape by simply entering it in the text box and hitting enter. This has saved me having to always hold down the up or down arrow to position a shape where I want it in the stack.

Anyway, here it is, but note that this is my first attempt at hacking a lua script, so don't expect perfection.

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

Code: Select all

function LM_SelectShape:HandleMessage(moho, view, msg)

	local mesh = moho:Mesh()
	if (mesh == nil) then
		return
	end

	local NewShapeID = self.shapeNumberBox:IntValue()-1

	-- Check NewShapeID against bounds
	if NewShapeID < 0 then
		NewShapeID = 0
	elseif NewShapeID > mesh:CountShapes()-1 then
		NewShapeID = mesh:CountShapes()-1
	end 

	moho.document:PrepUndo(moho.layer)
	moho.document:SetDirty()
	-- Set shape to requested level
	for i = 0, mesh:CountShapes() - 1 do
		if (mesh:Shape(i).fSelected) then
			if i > NewShapeID then
				-- Need to lower selected shape
				for j = 0, i - NewShapeID - 1 do
					mesh:LowerShape(i-j, false)
				end
			elseif i < NewShapeID then
				-- Need to raise selected shape
				for j = 0, NewShapeID - i - 1 do
					mesh:RaiseShape(i+j, false)
				end
			end
			
			self.prevSelID = NewShapeID
			LM_SelectShape:UpdateWidgets(moho)
			break
		end
	end	
	moho:UpdateUI()

end

Posted: Fri Sep 21, 2007 5:53 am
by Genete
Hey Rudiger!
That's a cool portion of script! I'll test it as far as I have time!
Thanks
-G

Posted: Tue Sep 25, 2007 9:42 pm
by Genete
Thank you very much Rudiger!

I've just drop the portion of code inside the 7feet's modified LM select shape and it works fantastically good!

You want to put a shape A under/over a shape B just look the number of the shape B, then select shape A and enter that number minus/plus 1 and that's all!!!

Cool!

Thanks again.
-G

Posted: Tue Sep 25, 2007 10:25 pm
by heyvern
This is FANTASTIC!!!!!!!!! YEEEEEHAAAAAA!!!!

I never would have thought of doing this!

I have incredibly complex layers in my projects with TONS of shapes. I have no problem figuring out where a shape needed to go but getting it there was a FREAKING NIGHTMARE!! I would sit there and click that dang button over and over and over and over.... and over and over... then check the order in the list... then click the button some more... until the shape was in the right spot.

It would be the same as if instead of flipping directly to page 356 in a book, you had to look at each page before getting there.

This could save literally hours of accumulated time spent working on complex vector layers. what could take me as much as 5 to ten minutes could be done in a few seconds.

Imagine a layer with bunches and bunches of repeated shapes, like a field of flowers or random objects!!!

This is an incredibly POWERFUL yet very simple addition to this tool!!!

-vern

Posted: Wed Oct 03, 2007 4:17 am
by Rudiger
Thanks Heyvern and Genete. Just glad to finally contribute after benefiting from the great scripts that you guys have written.

I often have characters with more than 500 shapes, and it really did get to the point where I would spend more time raising and lowering shapes than actually drawing. Now, if only I could work out to support multiple shapes at once. That would be sweet!!!!

Posted: Wed Oct 03, 2007 10:15 am
by heyvern
Hey Genete!

I just figured something out regarding shapes and names.

Apparently for some reason the shape name is a "userdata" and isn't really "readable" by the script interface. Also each time a file is opened this userdata "changes".

If you convert it to a string it is a series of numbers and letters. Each time you open the file that identification changes for each shape. However, the values remain constant through out a session in AS.

Couldn't that userdata value be used as an identifier for doing shape ordering? If you change the order that data stays the same. When the file is open the table reference could be created on frame 0 using the userdata.

The big problem is that you can't check the name or even if one exists. The name of a shape always returns the userdata value even if it is "empty".

But if you "matched up" the userdata identifier to a bone name in a table then you COULD keep track of shapes regardless of their order.

So if you moved shape "X" up six levels... you could still find "X" by using the bone name in the table and matching it to the userdata value that was converted to a string.

For instance bone "X" controls shape "X" order. When you change bone X to resort the table reference for the userdata is still stored with bone X. Later you change bone X again to change shape X's order. Bone X is still in the same spot in the table with a reference to shape X along with it. You can even store the level it is at.

You would have to make absolutely sure to go back to frame 0 to "reset" all the shapes to the original order when the file was opened. Otherwise the order would be permanently changed and the whole thing screwed up the next time the file was opened.

-vern

Posted: Wed Oct 03, 2007 10:41 am
by Genete
Well, it could be an improvement.

You can build your shapes - bones reference table everytime the embedded script is at frame 0 and not redo it when not at frame 0.

Cool.

But, ... would it allow do new things that cannot be done with sort_sahpes_by_bones embedded script?

That script works by now and I don't want to change it if no new feature is achieved. Want you? :wink:

-G

Posted: Wed Oct 03, 2007 1:01 pm
by funksmaname
Brilliant!
I think i suggested this somewhere when i first go this incredible script but maybe it got lost somewhere... :P

Excellent addition! nice work.