I feel like as soon as I think I understand something, I get an error that I can’t understand. I’m able to use the OpenDocumentFile node to open a second file, save it and then close it in the background (while another project is open). The issue I am running into is it appears that if I want to edit the file while open (say, purge unused elements), the node does not like the ‘document’ input I am sending it. Apparently the file that I have open in the background is a Revit.DB.Document, but the node only wants a Revit.Document input.
I have a similar issue with other document-driven nodes, such as clockwork’s ‘All Elements of Category+’. The nodes never affect the document that I link into them.
Well, that node works great, but for some reason I just cannot figure out why any changes that are made are not through the secondary document but in the main Revit session. I don’t understand why the nodes are not affecting the background document that is connected into them.
Background processing is a complex issue. The recent discovery from @john_pierson on utilizing reflection to wrap the elements seems fairly robust, so I expect some significant gains in the simplicity here, but that doesn’t mean we won’t run into other issues as more of these workflows are adopted. One such issue may be leading to mis-aligned pointers due to the significant volume of page faults (when your RAM isn’t enough so the CPU has to move data to your scratch disc) which are likely present in this type of workflow. Can you post what you’re seeing with the cross-crossing of document stuff?
You may also want to consider moving your efforts to a single Python node, zero touch node, or another means to ensure you never have to marshal more than one document between nodes at a time.
This may be an issue with the reflection method which Rhythm has recently implemented, but more likely it’s something else as @john_pierson is super thorough with putting stuff like this out there. Which Revit and Dynamo for Revit version was this in? Perhaps it could require an update to the Document.SaveAs node (which I don’t think is from Rhythm), or that the wrapper for your particular combination of Dynamo and Revit is blocking the new node from processing correctly due to pointer overwrite or other issues. The “single python node” may be your best bet if you have an immediate need.
As I experiment even more, I think a portion of the problem is that the ‘OpenDocumentFile’ does not appear to finish loading the file before these commands try and take place. A passthrough node does not appear to work with the OpenDocumentFile Node. Is there a way to confirm that the file is open before running further commands?