Jayme McColgan Posted December 9, 2022 Share Posted December 9, 2022 when i run a menu command plugin is it possible to sort selected objects by the order they were selected in? Quote Link to comment
Vectorworks, Inc Employee klinzey Posted December 9, 2022 Vectorworks, Inc Employee Share Posted December 9, 2022 No. Traversal is always done is creation order. The only way to do this would be to have the the menu run a temp tool to let the user select the objects. You can then capture the order the objects are selected as they are clicked. 2 Quote Link to comment
Popular Post MullinRJ Posted December 9, 2022 Popular Post Share Posted December 9, 2022 Hi @klinzey, Last week I tested how the order of objects are returned by ForEachObject() to clarify how it responds in Single-Layer vs. Multi-Layer modes. I found in Single-Layer mode it returns objects in Stacking Order, bottom of stack first, top of stack last; but in a Multi-Layer mode (Show-Snap-Modify Others) it still searches objects on a layer the same (bottom to top) but it searches the layers top to bottom. This was not obvious or expected, but I'm glad I finally looked. I hope this helps others who are curious about how ForEachObject() works. Raymond 5 Quote Link to comment
JBenghiat Posted January 2, 2023 Share Posted January 2, 2023 You can think of the Vectorworks file format as an xml-like node tree with parent, container objects that contain child objects. Layers, groups, and symbol definitions are all examples of container objects. In traversing a list, if an object is a container, you go into the container, iterate through objects until the last contained, and then continue with the object after the container. So, in the case of layers, you iterate through every object in the layer, then move to the next layer. You can get some sense of the structure here: https://developer.vectorworks.net/index.php/SDK:The_Vectorworks_Environment Traversal is via object's stacking order, from bottom to top. Unless you do a Send Forward/Back, this will be from oldest object to newest. Selection state is just a true/false flag for each object, so iterating over selected objects still goes in stacking order, but also checks if the selected status is true. 2 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.