Page 2 of 4
Posted: Sun Nov 02, 2008 6:51 pm
by synthsin75
Yeah, I'm already planning on extending this to select by vectors, but since you can't see the points from another layer, I'll have to select by edge. I'm hoping I can do that as well as the current select by shape.
A really cool simple workaround is to just have a tiny filled box on each layer making sure they don't overlap so you can select them.
Yeah, I ment to mention that. Might be a good idea to attach a vector line from these boxes to the shapes they're with, that way you can easily tell which box is on which layer (with a hidden shape).
What I want to end up doing is making this layer selection work just like shape sorting. Ctrl+UP/DOWN would select up/down through the layer stack, UP/DOWN would move layers up and down in the stack ( I really need to find out what that animation channel is called and if I can keyframe it by script).
----------------------
If I added the code for this directly to the select shape tool (as is), so you don't need the separate script (basically useless by itself), do you think it'd be something people would want/need? I'd be happy to wait until I do the further stuff, but if it's useful, it might as well be in use in the meantime.
Let me know what you think.

Posted: Sun Nov 02, 2008 7:37 pm
by synthsin75
I figured out how to stay on the current layer if no shape was picked:
Cool! Thanks! I had tried something similar, but I didn't go far enough up to catch the layer before the click.

Posted: Sun Nov 02, 2008 7:45 pm
by heyvern
I think it would be better to include the tool and/or have instructions to paste/add the "reference" for layer selecting to the tools. I plan to add this to all of my VECTOR editing tools because that is when I would use it the most. The benefit of this is that the code only lives in ONE PLACE. The same code is not repeated in a bunch of tools.
I rarely use the select shape tool because Fazek's translate point tool picks shapes as well. I really need to hop around layers when I'm editing vectors. Currently I have several "extra" bits in my own custom keydown utility script. I can just add this code to my utility script and I won't even need to edit the tools themselves.
-----------------
Simple Option
-----------------
For simple installation using the "reference" technique all the user needs to do is add that OnMouseDown function to any tool they want this functionality;
Code: Select all
function LM_SelectPoints:OnMouseDown(moho, mouseEvent)
Syn_SelectLayer:OnMouseDown(moho, mouseEvent, view)
end
Just add that code to any tool and it will use your new tool. I am pretty sure all the tools have an OnMouseDown function so really all you need to do is stick in this part inside the existing function:
Code: Select all
Syn_SelectLayer:OnMouseDown(moho, mouseEvent, view)
--------------------
Advanced Option
--------------------
Or you can add the code from your tool to the lm_utilities.lua script or to your own custom utilities script (better for portability) in a mousedown function.
Add this code to the lm_utilities.lua file:
Code: Select all
function MOHO.OnMouseDown(moho, mouseEvent, view)
-------
local mesh = moho:Mesh()
if (moho.layer:Parent() == nil) or (mesh == nil)then
return
end
local prevMousePt = LM.Point:new_local()
local prevSelID = -1
local layer = moho.layer
local prevLayer = moho.layer
local parlayer = layer:Parent()
local layernum = parlayer:CountLayers()-1
local shapefound = false
for i = layernum, 0, -1 do
local layerobj = parlayer:Layer(i)
--print(tostring(layerobj))-----------------------------
if (layerobj:LayerType() == MOHO.LT_VECTOR) then
moho:SetSelLayer(layerobj)
prevMousePt:Set(mouseEvent.pt)
prevSelID = mouseEvent.view:PickShape(mouseEvent.pt)
--shapenum = mesh:CountShapes()
--shapeiter = shapenum -1
for i = 0, mesh:CountShapes() -1 do
mesh:Shape(i).fSelected = false
--print(tostring(mesh:Shape(i)))--------------------
if (prevSelID >= 0) then
mesh = moho:Mesh()
mesh:Shape(prevSelID).fSelected = true
--print(tostring(mesh:Shape(prevSelID)))-------
shapefound = true
break
end
end
if (shapefound == true) then
break
else
moho:SetSelLayer(prevLayer)
end
end
moho:UpdateSelectedChannels()
end
mouseEvent.view:DrawMe()
moho:UpdateUI()
end
Then look for a "OnMouseDown" function in any of the tools you want this fucnctionality and add this line inside that function:
Code: Select all
MOHO.OnMouseDown(moho, mouseEvent)
I am pretty sure that almost all the tools have an OnMouseDown function otherwise they wouldn't be able to do anything. There might be issues with conflicting key commands (CTRL + SHIFT).
I just did the above enhancement with my FA point tools and it works good so far.
The benefit of putting the code in a utilities script is that it doesn't require the tool to be in the tool palette. You are adding the functionality very simply directly to the tools themselves. If you want to update the script later no need to edit the tools, just edit the utility script.
-----
p.s.
The beauty of custom utility scripts is that once they are referenced in all the tool scripts you can add new things without needing to install a new tool or edit the tools. If you have a reference to a custom utility script OnMouseDown function and later decide to add a NEW function or cool trick that does something else just add it to the utility script.
-vern
Posted: Mon Nov 03, 2008 4:07 am
by synthsin75
Thanks for the tips Vern. I had just been thinking that I'll probably end up doing my own utility and modified script set. I can see why Fazek reworked all the tools he did.
Woohoo!!
I got the select layer by construction curve (vector) to work! It works great. Now you can select a layer by any visible vector line.
I just need to figure out how to do both now. I like selecting layers by shape, but if they are hidden by other shapes or not visible, I need to select layers by vector line. I've tried a little, but haven't yet figured out how. It needs to select by shape unless it finds a vector, and then select by vector. That way I don't need a further modifier key for these differing modes.
Even if I don't figure this part out, I'll post it tomorrow. It works good, but if you have visible shapes it defaults to layer selection by shape even if you try clicking a vector.

Posted: Mon Nov 03, 2008 4:43 am
by chucky
This looks really useful thanks synth, for all your scripting endeavours, I can't wait to try your new tools when I get a moment.
Posted: Mon Nov 03, 2008 6:03 am
by heyvern
synthsin75 wrote:Thanks for the tips Vern. I had just been thinking that I'll probably end up doing my own utility and modified script set. I can see why Fazek reworked all the tools he did.
Woohoo!!
I got the select layer by construction curve (vector) to work! It works great. Now you can select a layer by any visible vector line.
I just need to figure out how to do both now
I was thinking a check box option in the select layer tool might work. This of course means you would need the tool installed instead of using the utility script (which is fine by me since that would be the only really simple choice I can see).
You could select your layer tool, check a box for shape or edge selection then use the other tools as normal. AS "remembers" the settings for a tool when referenced by other tools in this way. Ultimately it would be nice if ALL the tools had the check box for this option... but that's a huge major modification.
Once again at a spot where I growl and curse wishing for more "robust" key modifiers and script features.

The worst of it is the difference between mac and win modifier keys.
I will play around with this and see if I can come up with anything to help out.
GREAT SCRIPT! FANTASTIC! I LOVE IT! I am using it already! It really really is very handy! What a time saver.
------
p.s. I think the bigger issue about all of this is the difficulty in making changes to the tools and the set up for the average user. I can easily go in and add stuff to the utility script or modify all of my tools but the "regular" animator who just wants to use AS and animate shouldn't have to figure that out. With the ability of lua to read and write/edit files fairly easily there should be a way to be able to add/edit tools and scripts using some kind of interface.
For instance a pop up window with a list of tools. You choose "syn_select_layer" tool from a menu and then "apply" its functionality to other tools from a list. The script would either edit those tools or edit the utility script. It would put in comments in the code so those "snippets" can be removed just as easily. Reboot AS and you have the tool installed.
That is my dream anyway.
-vern
Posted: Mon Nov 03, 2008 6:41 am
by synthsin75
Yeah, then we're back in the realm of my add-ons script. I still intend on doing that (and using it to modify other scripts is a natural extension of the idea I think), but I was itching to actually get something done so I put it on the backburner.
I still think I can get it to work both ways without any extra user interface (check box, etc). It'll just take a little time to figure out.
Right now, I'm just planning on posting my own set of reworked tools to incorporate this, and future, features. That way the average user can just load them up like normal and overwrite them as I post improvements. Anyone who needs more custom access to these features will probably be a scripter anyway. I intend to retain all of Fazek's features, so no one'll have to give up anything to use my tools.
Like I said, I'll post the dual-method select layer tool tomorrow. It work pretty good already. If you click a fill, it selects that layer. If there is no fill, it selects by vector. And it can do a mix of these seemlessly (even on the same layer). Just right now the only way to select hidden shapes is to turn the displayed fills off. That may be good enough though.

Posted: Tue Nov 04, 2008 1:48 am
by synthsin75
As promised, here's the select layer tool the selects layer by either shape or vector curve. Instead of needing a filled shape to select hidden shape's layer, now you only need a single extra vector line that can be clicked. Or just turn off fills.
Download it here.
I'm still working on getting it to select by curve even if a shape is in the way.
Let me know if ya like it.

Posted: Tue Nov 04, 2008 5:37 am
by chucky

You FREAKING LEGEND Synth, after trying this tool for three and a half seconds I was singing the halleluiah chorus.
While you are at it we still all need that 'generate Oscar winning feature animation' button, all things are now possible.

Posted: Tue Nov 04, 2008 5:44 am
by heyvern
This is one of those gems of a tool script that is so simple but so useful. I was amazed at how sparse the code is. Great job!
edit: I don't mind the shape/curve selection issue. Works great for my needs.
-vern
Posted: Tue Nov 04, 2008 6:01 am
by heyvern
Holy cow!
For some reason it works WITHOUT using the modifier keys with my utility script set up. I put the code from the tool in a OnMouseDown function in lm_utilities.lua.
I added that code to use this function to my fa_select_points and fa_translate_points tools and now I don't have to use the modifier keys. I just click on the shape or curve and it switches layers.
Is this new? Or could it be the way I'm using it? It works fine. It works just like it should. this means that possibly... you could use the modifier keys for "switching" between shape/curve selection.
Will look into this.
-vern
Posted: Tue Nov 04, 2008 6:39 am
by chucky
If you want here's a choice of tool symbols for your neat script synthsin
syn_select_icon
I just put the tool in the regular tools folder and started selecting.
I might be using it incorrectly but it still works great for selecting all the shapes in a group folder.
Posted: Tue Nov 04, 2008 1:14 pm
by synthsin75
I added that code to use this function to my fa_select_points and fa_translate_points tools and now I don't have to use the modifier keys. I just click on the shape or curve and it switches layers.
I hadn't thought of that, but yeah, it should work well replacing any tools selection method. There may be some selection features it displaces though (like marquee selection).
I'm thrilled this is so useful. I still want to do some more stuff before I release it to the general AS user.
Thanks Chucky, but right now the select layers tool doesn't do enough by itself to need an icon (but I like them).
I'll keep you posted on further developements.

Posted: Tue Nov 04, 2008 1:35 pm
by VĂctor Paredes
heyvern wrote:For some reason it works WITHOUT using the modifier keys with my utility script set up. I put the code from the tool in a OnMouseDown function in lm_utilities.lua.
I added that code to use this function to my fa_select_points and fa_translate_points tools and now I don't have to use the modifier keys. I just click on the shape or curve and it switches layers.
Is this new? Or could it be the way I'm using it? It works fine. It works just like it should. this means that possibly... you could use the modifier keys for "switching" between shape/curve selection.
the same thing happened to me, but it make my tools unworkeable (they were always searching for another layer). I had to erase the codelines from add and translate points. I haven't tried the new tool yet, but the code heyvern put was a good idea...
Posted: Tue Nov 04, 2008 1:41 pm
by synthsin75
Try this. After the scripts 'onMouseDown' function, paste this code:
Code: Select all
if (mouseEvent.ctrlKey) and (mouseEvent.shiftKey) then
Syn_SelectLayer:OnMouseDown(moho, mouseEvent)
return
end
I plan on releasing this already in a new tool set, but that may be a little while.