Hi @kandennti
thank you for your answer and your example code.
I think it is always good to have some sample implementation from somebody who knows what he/she is doing.
As far as i can see from your example, you are also opening the active document, implying, that the Drawing is already open in the UI, correct?
drawDoc :adsk.drawing.DrawingDocument = _app.activeDocument
My initial idea was to open a 3D file and then export the linked drawing (without the user having to open the drawing first). This might not be a necessary function, but now i am kind of knee deep on the issue. 😄
I can manage to identify the linked drawing and opening it, but no PDF file gets created.
I have tried some more and there is in fact a race condition.
drawingDoc = app.documents.open(drawingDataFile)
drExpMgr = drawingDoc.drawing.exportManager
pdfOptions = drExpMgr.createPDFExportOptions(<path>)
result = drExpMgr.execute(pdfOptions)
- Executing this returns result=True, but no PDF is created
- Also invoking the Eventhandler app.documentOpened.add(onDocumentOpened) does not solve this. It fires, but the file is still loading the content
The only way i found to enforce the complete loading of the drawing file is to open a UI messagebox after opening the datafile.
ui.messageBox('Sorry...you gotta wait until the drawing is loaded...', '', 0, 2)
For some reason, the OK button can only be pressed once the drawing is fully loaded. Then the export is fired and also generates the desired PDF file. But this is quite a hacky workaround.
I did, however, not find a way to get the same signal... but i am also not the greatest programmer 🙂
What do you think? Can you see similar behavior?