Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
On 16/08/2018 at 15:00, xxxxxxxx wrote:
This problem was seemingly simple to solve but is giving me a hard time. I have the standard procedure for iterating through the object hierarchy from a selected object but I don't want it to keep going after the last object in the immediate hierarchy. I'm using this as a starting point:
def GetNextObject(op) : if op==None: return None if op.GetDown() : return op.GetDown() while not op.GetNext() and op.GetUp() : op = op.GetUp() return op.GetNext() def IterateHierarchy(op) : if op is None: return while op: op = GetNextObject(op) def main() : start_object = doc.GetActiveObject()
So far the only way I've found to get it to search within the immediate hierarchy only is to give IterateHierarchy function the same argument twice, which is the active object, so I can have a reference to the original object while the other is getting replaced by the next object in the sequence . I want the code to say "if you get back to the active object(original object) then end the loop. It seems a bit sloppy the way I did it and i'm sure I am doing wrong. Is there an easier way to start from an object and only search from there down?
On 17/08/2018 at 02:32, xxxxxxxx wrote:
Hi Motion4D, unfortunately, we can only provide you support for API related question, not algorithm questions.
But with that said, here is tree way to do it but there is a bunch of others, is up to you to choose the one which will be the more efficient for you:
Hope it helps, Cheers, Maxime!
On 17/08/2018 at 09:45, xxxxxxxx wrote:
Great suggestions Maxime! You rock!