Access documents in active window without recursive scroll?

Michael Milez

Access documents in active window without recursive scroll?

CATIA.Documents.Item(i) includes all documents loaded in the CATIA session. Is there a way to perform a similar function for documents only in the active window?

I understand that it is technically possible by recursively scrolling through the tree, but I would like to get around working on each instance of the document if possible for various scenarios.

Josh Bender

RE: Access documents in active window without recursive scroll?
(in response to Michael Milez)

I haven't been able to find a way around that. Recursively scrolling ends up being the easiest way to sort through large products quickly.

Alternatively, you could use the selection object (catia.activedocument.selection) to do a search for all the products in the active window and then sort unique documents into a collection. But that doesn't buy you much except to avoid using recursion. The search function could also take quite a while if you have an large product with a bunch of instances.

CATIA.ActiveDocument.Selection.Search ("(('Product Structure'.Product + 'Assembly Design'.Product) + 'Process Applications'.Product),all")

Michael Milez

RE: Access documents in active window without recursive scroll?
(in response to Josh Bender)

Josh, thank you for the response.

I've been getting around it by creating a scripting dictionary and adding the part numbers that have been worked on to the list and then checking the subsequent part numbers against the list and if it exists to bypass it. But that still takes time and I feel like it's just another place where errors can be made.

So while I was hoping for better news, lol, I guess I'll just keep pushing forward.

Thank you again!

Little Cthulhu

RE: Access documents in active window without recursive scroll?
(in response to Michael Milez)

Recursion approach in CATScript should take little time even with large assemblies. Post your code if you want us to review it.

Michael Milez

RE: Access documents in active window without recursive scroll?
(in response to Little Cthulhu)

Little,

I was able to reduce the runtime down to a normal amount by utilizing the fix I mentioned earlier, where I add the part number to a scripting dictionary once I do something to it or check for something, and then checking each item in the recursive scroll to see if the part number exists and skipping over each instance where the part number does exist already. This approach works fine.

I was just hoping there was a better way for Catia to identify documents only in the active window as opposed to scrolling through each instance.

Thank you!