- What would you like to request: An option in object picking that unpicks any currently picked instances of an object and picks any that werent picked
- Why you are requesting it: I am trying to make a thing where it outlines the object on top of some overlapping objects, then unpicks the top one and selects the rest to turn their outline off
I believe you could do that with new repeat for each
Where i want to point out i would see perfect sense in having unpick all objects action when we have pick all objects action
I agree with both post. An invert picked function would be nice. As would an Unpick all. There’s an extension called Unpick All Objects. It used to be called Object Picking Tools. Maybe, if they don’t want to add it to GD, the creators could add it to their extension.
Sometimes, you can pick the opposite objects by inverting the condition. That’s not always possible or practical especially with multiple conditions or steps or a large amount of objects.
Another option is to select the unpicked objects by doing something like modifying a property like opacity or adding an object variable named Picked and setting it to true for the picked objects. You could then use pick all and check if the variable is false. Again, it’s not always practical and a devoted function would be easier and much more efficient.
I use the Unpick extension all the time… but @Joshua2 , I don’t think you need it for the example you gave. What you should be doing is disabling the outline when you have all of the objects picked. Then find the highest Z-order (or whatever you’re doing to get the “top” object) and enable the outline.
I did get AI to make this code but since i haven’t used javascript before I can’t confirm its effeciency. If you want to download the extension I have it here: https://drive.google.com/file/d/1UhndtSnS_N4mKQaLqPJHvBqgDF_wGooy/view?usp=sharing
Here is a video of it in use: https://drive.google.com/file/d/1EsDHPIkr4Gqe3EpQaxjxCjjH8hroxVDy/view?usp=sharing
const objectName = eventsFunctionContext.getArgument("ObjectName");
const lists = eventsFunctionContext.getObjectsLists("Objects").items;
const allObjects = runtimeScene.getObjects(objectName);
for (const listName in lists) {
const list = lists[listName];
const pickedSet = new Set(list);
list.length = 0;
for (const obj of allObjects) {
if (!pickedSet.has(obj)) {
list.push(obj);
}
}
}
What happens when you have two groups of buttons though? Wouldn’t it pick all of them ( except the first one)
@magicsofa
I’m not sure i understand what you mean.
I did test it on a group of buttons and it seemed to unpick them all.
const pickedObjects = eventsFunctionContext.getObjectsLists("Objects").items;
const allObjects = runtimeScene.getObjects(eventsFunctionContext.getArgument("ObjectName"));
for (const x in pickedObjects) {
const list = pickedObjects[x];
const pickedSet = new Set(list);
list.length = 0;
for (const y of allObjects) {
if (!pickedSet.has(y)) {
list.push(y);
}
}
}
For some context here:
- Outside of very select few event actions/conditions in the engine, nearly everything event-wise are extensions. As an example, all of the button objects in the object list are extensions. Some extensions are just included automatically.
- You generally should never worry about using an extension that is in the main (non-community list), and the community list is generally fine as well. The old “Object Picking Tools” (now “Unpick all objects”) is incredibly useful and one of the most commonly used extensions I interact with.
- What you’re describing is already doable without new actions being added (and what you’re asking for wouldn’t do what you’re describing).
- The updated “for each” event allows you to set an “ordered by”, and you can do ObjectName.ZOrder() as the order as well as set the “limit” to 1.
- If it’s descending, it’ll be highest Z order first. If it’s ascending, it’ll be lowest Z order first. (Thanks Davy for talking through this one with me)