Technical question
Moderators: Víctor Paredes, Belgarath, slowtiger
OK was I supposed to put this in the ulities folder?
Is that why you are all talking about modifyer keys?
Or is this script meant to replace the old shape select?
Have I missed something?
I only did the icon because it showed up as a new tool without an icon in the 'other' section, I think I might keep it there as a distinct tool, for the moment. (I really don't like messing with Mikes originals.)
That said Synthsins version is definitey the new tool of choice, I will probably only need the original in case of some kind bizarrre and unlikely code meltdown.
Thanks again.
Is that why you are all talking about modifyer keys?
Or is this script meant to replace the old shape select?
Have I missed something?
I only did the icon because it showed up as a new tool without an icon in the 'other' section, I think I might keep it there as a distinct tool, for the moment. (I really don't like messing with Mikes originals.)
That said Synthsins version is definitey the new tool of choice, I will probably only need the original in case of some kind bizarrre and unlikely code meltdown.
Thanks again.
- Víctor Paredes
- Site Admin
- Posts: 5826
- Joined: Tue Jan 25, 2005 3:18 pm
- Location: Barcelona/Chile
- Contact:
oh!, thank you, now it works perfectly!synthsin75 wrote:Try this. After the scripts 'onMouseDown' function, paste this code:I plan on releasing this already in a new tool set, but that may be a little while.Code: Select all
if (mouseEvent.ctrlKey) and (mouseEvent.shiftKey) then Syn_SelectLayer:OnMouseDown(moho, mouseEvent) return end
I love it WITHOUT the modifier keys. It works great and my select and translate tools still work fine during normal editing. It works now just like Adobe Illustrator or any other "layer" based application. Automatic switching of layers. Brilliant.
There is a teeny tiny "glitch" when clicking on a vector or shape that switches layers that deselects the points and shape immediately after selecting them but I think I can fix that easily in the code. It only happens when I click on a shape or curve that is on a different layer.
Another tiny glitch is that it deselects previously selected shapes and points on a layer. Not a biggy but sometimes I like to keep points selected (a complex selection) on a layer while I check things on other layers. I think this also can easily be fixed in the code by creating a temporary "selection" table to preserve the current selection state of a layer.
-vern
There is a teeny tiny "glitch" when clicking on a vector or shape that switches layers that deselects the points and shape immediately after selecting them but I think I can fix that easily in the code. It only happens when I click on a shape or curve that is on a different layer.
Another tiny glitch is that it deselects previously selected shapes and points on a layer. Not a biggy but sometimes I like to keep points selected (a complex selection) on a layer while I check things on other layers. I think this also can easily be fixed in the code by creating a temporary "selection" table to preserve the current selection state of a layer.
-vern
Marquee selection works fine. Just like it does normally. It does not switch layers.synthsin75 wrote:There may be some selection features it displaces though (like marquee selection).
Keep in mind when you use "multiple" OnMouseDown functions from different tools or scripts they ALL get "processed". So they all try to work if you follow me. One function does not "override" another function. They all get processed. As long as there isn't "duplication" of code... like two functions that do the exact same thing with different results it shouldn't be too much of a problem.
In my testing it works great!
I FREAKING LOVE THIS!!!!!

-vern
- synthsin75
- Posts: 10324
- Joined: Mon Jan 14, 2008 2:20 pm
- Location: Oklahoma
- Contact:
Chucky,
Yeah, you can use it as a standalone tool (I have while testing it). With a shortcut assigned, it'd still be useful. I try not to add to the already sparse available shortcuts, that's why I'd add it to different tools. Selgin was just asking about modifying tools himself to include this functionality. If you installed the syn_select_shape tool then just replace the syn_select_layer tool with the latest one and you're golden.
Selgin,
Glad to help. Please let me know what you think of it.
Vern,
Both of these are very good points that I was intending to address, but if you solve them first, please let me know how.
I was intending to post a new set of tools that all include this, but do you think that would be too bold to replace Fazek's? (Granted all of mine would be modifications of Fazek's.) I don't know of any easier way to make it accessible to the average user. Very few of us are willing to go monkeying with the tools.
On the plus side, I (an active scripter) would be maintaining and developing those tools, so I kind of figure it works out.

Yeah, you can use it as a standalone tool (I have while testing it). With a shortcut assigned, it'd still be useful. I try not to add to the already sparse available shortcuts, that's why I'd add it to different tools. Selgin was just asking about modifying tools himself to include this functionality. If you installed the syn_select_shape tool then just replace the syn_select_layer tool with the latest one and you're golden.
Selgin,
Glad to help. Please let me know what you think of it.
Vern,
Mmm, using it as a standalone, the shapes stay selected when switching layers, but I haven't figured out how select the vector curves. (May be different on a Mac though.)Vern wrote:There is a teeny tiny "glitch" when clicking on a vector or shape that switches layers that deselects the points and shape immediately after selecting them but I think I can fix that easily in the code.
Yeah, I would like it to remember each layers selections as well. Might be able to just get rid of the code that sets selection false. Haven't tried it yet.Another tiny glitch is that it deselects previously selected shapes and points on a layer.
Both of these are very good points that I was intending to address, but if you solve them first, please let me know how.
I was intending to post a new set of tools that all include this, but do you think that would be too bold to replace Fazek's? (Granted all of mine would be modifications of Fazek's.) I don't know of any easier way to make it accessible to the average user. Very few of us are willing to go monkeying with the tools.
On the plus side, I (an active scripter) would be maintaining and developing those tools, so I kind of figure it works out.

- synthsin75
- Posts: 10324
- Joined: Mon Jan 14, 2008 2:20 pm
- Location: Oklahoma
- Contact:
Okay, I've fixed both those 'gliches' Vern. You may have already done so. If not, let me know if you need it.
Now it doesn't do any shape or curve/point selection at all. This leaves any previous selections intact as you switch from layer to layer. This only work if you use it with a modifier key though. Using it without, immediately does that tool's regular selection on where you click. I don't think there is an easy way around that.

Now it doesn't do any shape or curve/point selection at all. This leaves any previous selections intact as you switch from layer to layer. This only work if you use it with a modifier key though. Using it without, immediately does that tool's regular selection on where you click. I don't think there is an easy way around that.

- synthsin75
- Posts: 10324
- Joined: Mon Jan 14, 2008 2:20 pm
- Location: Oklahoma
- Contact:
Here you go, Vern! All of your requests for this tool have been solved. You'll need this new version so it doesn't do any selection of shapes or curves.
Download it here.
You'll need to do just a bit more to add this to other tools, but this method will preserve all of your selections on each layer, and do so without needing to use a modifier key to use it.
Just add this below the tool's OnMouseDown function:
And be sure to add an extra 'end' at the end of the OnMouseDown function, to close the 'if'. (For most tools, just before the OnMouseMoved function)
Enjoy
Download it here.
You'll need to do just a bit more to add this to other tools, but this method will preserve all of your selections on each layer, and do so without needing to use a modifier key to use it.

Just add this below the tool's OnMouseDown function:
Code: Select all
curlayer = moho.layer:Name()
Syn_SelectLayer:OnMouseDown(moho, mouseEvent)
nextlayer = moho.layer:Name()
if (curlayer == nextlayer) then
Enjoy

- synthsin75
- Posts: 10324
- Joined: Mon Jan 14, 2008 2:20 pm
- Location: Oklahoma
- Contact:
Okay, I just got this working the way I have wanted. This version will select by vector edges from the bottom of the layer stack up, and if none found, it will select by shapes from the top down.
What this means is that, if you can judge where the edge of a hidden shape is, you can just click on that to select the layer of that hidden shape.
Download it here.
Please check this out to see how useful you may find it. With really complex meshes, this could be more trouble than it's worth. If so, it's now written so it'd be easier to add a tool option for selection mode.
--------------
Which makes me wonder. Is there a way to have a tool, called by other tools, work in different 'modes' depending on which tool has called it? Would I somehow have to define a variable in each 'calling' tool that can be used by the 'called' tool?
For example, say I am calling this select layer script from the translate points tool. I might want it to only select layers by vectors while I might want the select shape tool to only select layers by shapes.
Offhand, I'm assuming I can do something like save a pref for the select layer script within the calling tool? I don't know if prefs can be used that dynamically.
Maybe assign a variable like: Syn_SelectLayer.mode ,within the calling tool, and then use that within this script? Maybe that can only be done with functions?
Any ideas, or easier solutions greatly appreciated. Unless that seems like overkill.
What this means is that, if you can judge where the edge of a hidden shape is, you can just click on that to select the layer of that hidden shape.
Download it here.
Please check this out to see how useful you may find it. With really complex meshes, this could be more trouble than it's worth. If so, it's now written so it'd be easier to add a tool option for selection mode.
--------------
Which makes me wonder. Is there a way to have a tool, called by other tools, work in different 'modes' depending on which tool has called it? Would I somehow have to define a variable in each 'calling' tool that can be used by the 'called' tool?
For example, say I am calling this select layer script from the translate points tool. I might want it to only select layers by vectors while I might want the select shape tool to only select layers by shapes.
Offhand, I'm assuming I can do something like save a pref for the select layer script within the calling tool? I don't know if prefs can be used that dynamically.
Maybe assign a variable like: Syn_SelectLayer.mode ,within the calling tool, and then use that within this script? Maybe that can only be done with functions?
Any ideas, or easier solutions greatly appreciated. Unless that seems like overkill.

- synthsin75
- Posts: 10324
- Joined: Mon Jan 14, 2008 2:20 pm
- Location: Oklahoma
- Contact:
Ooops.
I need to edit that code I posted above for adding syn_select_layers to a tool. The above works on layer name, so it isn't 100% reliable (depending on how careful you are with duplicate layer names).
This code will solve that though (with the added 'end' as above).
Until I tried this, I had no idea if 'tostring' would work for that.


I need to edit that code I posted above for adding syn_select_layers to a tool. The above works on layer name, so it isn't 100% reliable (depending on how careful you are with duplicate layer names).
Code: Select all
curlayer = tostring(moho.layer)
Syn_SelectLayer:OnMouseDown(moho, mouseEvent)
nextlayer = tostring(moho.layer)
if (curlayer == nextlayer) then
Until I tried this, I had no idea if 'tostring' would work for that.

Yes, you can have each tool work differently when calling another tool. You would need to send an argument with the function.
For instance, inside a tools OnMouseDown function you call YOUR tool or script and include a variable...
So if the tool calling the function from your custom tool is the "translate points" tool and you want it to do something different, just haver your script check that extra variable. This is just an example.
Great idea. It never occurred to me to do that.
-vern
For instance, inside a tools OnMouseDown function you call YOUR tool or script and include a variable...
Code: Select all
local myToolVar = translatePoints
Syn_SelectLayer:OnMouseDown(moho, mouseEvent, myToolVar)
Code: Select all
function Syn_SelectLayer:OnMouseDown(moho, mouseEvent, myToolVar)
if (myToolVar == translatePoints) then
do something different or set other variables etc
end
.... do a bunch of other stuff... check for other tools etc...
end
Great idea. It never occurred to me to do that.
-vern
- synthsin75
- Posts: 10324
- Joined: Mon Jan 14, 2008 2:20 pm
- Location: Oklahoma
- Contact:
Cool! Thanks Vern!
That means I can make it select layers by vectors for drawing tools and shapes for shape tools. It'll take a little while to add that. (I'm working on further stuff at the moment)
I may end up doing radio buttons for the standalone tool so that the user can choose between shape, vector, or both selection modes.

That means I can make it select layers by vectors for drawing tools and shapes for shape tools. It'll take a little while to add that. (I'm working on further stuff at the moment)
I may end up doing radio buttons for the standalone tool so that the user can choose between shape, vector, or both selection modes.

- synthsin75
- Posts: 10324
- Joined: Mon Jan 14, 2008 2:20 pm
- Location: Oklahoma
- Contact:
I might have explained this here or in another thread.
The layer is determined by it's order in the layer palette. A layer ID changes if you change it's order in the layer palette. You can't rely on the layer ID. Just as you really can't rely on a bone or points ID but they don't change as much during animation.
Your best bet is to stick with the layer object as much as possible. You would need that to do anything to a layer anyway. You could loop through all the layers and use the name to find the layer ID. The problem with identifying layers is that they can be nested. There is no way to loop through ALL the layers at one time like you do with bones. You have to cycle through top layers in the hierarchy and then repeat that if a layer is a group. A layer at the top level cold have an ID of "12"... but... another layer inside a group could ALSO have an ID of "12". With bones or points this is impossible.
Can you tell me precisely why you need the layer ID rather than the layer object? There may be a way to do what you need without needing the ID.
-vern
The layer is determined by it's order in the layer palette. A layer ID changes if you change it's order in the layer palette. You can't rely on the layer ID. Just as you really can't rely on a bone or points ID but they don't change as much during animation.
Your best bet is to stick with the layer object as much as possible. You would need that to do anything to a layer anyway. You could loop through all the layers and use the name to find the layer ID. The problem with identifying layers is that they can be nested. There is no way to loop through ALL the layers at one time like you do with bones. You have to cycle through top layers in the hierarchy and then repeat that if a layer is a group. A layer at the top level cold have an ID of "12"... but... another layer inside a group could ALSO have an ID of "12". With bones or points this is impossible.
Can you tell me precisely why you need the layer ID rather than the layer object? There may be a way to do what you need without needing the ID.
-vern
- synthsin75
- Posts: 10324
- Joined: Mon Jan 14, 2008 2:20 pm
- Location: Oklahoma
- Contact:
Well I just figured out doing something like this to get the ID/object correlations in a table:
I do only need the layer objects for manipulation, but I need to know which layer object is immediately above and/or below the current layer. I was thinking that, with the layer IDs, I could get these exact layer objects.
But perhaps there's an easier way?
Code: Select all
for i = 0, moho.layer:Parent():CountLayers()-1 do
layerobj = moho.layer:Parent():Layer(i)
layertable[i] = layerobj
print(i .. " equals " .. tostring(layertable[i]))
end
But perhaps there's an easier way?