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

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

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

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

Postby 7feet » Sun Mar 27, 2005 5:08 pm

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
User avatar
7feet
 
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.

Postby anigreator » Sun Mar 27, 2005 6:26 pm

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!
anigreator
 
Posts: 36
Joined: Tue Mar 22, 2005 11:47 am

Postby LittleFenris » Sun Mar 27, 2005 9:03 pm

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.
User avatar
LittleFenris
 
Posts: 246
Joined: Thu Mar 10, 2005 7:29 pm
Location: USA!

Postby anigreator » Sun Mar 27, 2005 9:26 pm

Which is exactly what this new tool does. :)
anigreator
 
Posts: 36
Joined: Tue Mar 22, 2005 11:47 am

Postby 7feet » Sun Mar 27, 2005 10:04 pm

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
User avatar
7feet
 
Posts: 840
Joined: Wed Aug 04, 2004 5:45 am
Location: L.I., New Yawk.

Postby pixelwks » Mon Mar 28, 2005 1:16 am

Very very good!
User avatar
pixelwks
 
Posts: 32
Joined: Fri Dec 10, 2004 6:43 pm
Location: NYC

Postby Víctor Paredes » Fri Jun 29, 2007 11:19 pm

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.
User avatar
Víctor Paredes
 
Posts: 4813
Joined: Wed Jan 26, 2005 12:18 am
Location: Ireland

Postby Rudiger » Fri Sep 21, 2007 12:44 am

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
Rudiger
 
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Postby Genete » Fri Sep 21, 2007 5:53 am

Hey Rudiger!
That's a cool portion of script! I'll test it as far as I have time!
Thanks
-G
User avatar
Genete
 
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Postby Genete » Tue Sep 25, 2007 9:42 pm

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
User avatar
Genete
 
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Postby heyvern » Tue Sep 25, 2007 10:25 pm

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
User avatar
heyvern
 
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Postby Rudiger » Wed Oct 03, 2007 4:17 am

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!!!!
Rudiger
 
Posts: 786
Joined: Sun Dec 18, 2005 2:25 am

Postby heyvern » Wed Oct 03, 2007 10:15 am

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
User avatar
heyvern
 
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Postby Genete » Wed Oct 03, 2007 10:41 am

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
User avatar
Genete
 
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Postby funksmaname » Wed Oct 03, 2007 1:01 pm

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.
User avatar
funksmaname
 
Posts: 3105
Joined: Tue May 29, 2007 11:31 am
Location: Nelson, New Zealand

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests