How to wait for AutoCAD document to finish loading before proceeding in code
Mostrar comentarios más antiguos
Hi,
We have a Matlab application creating and working with AutoCAD drawings through COM interface. This is buggy, sometimes it works and mostly not. I have tracked down the issue to the following:
When creating the drawing, I have tried to add pause at different ranges before proceeding in the code, but this does not seem to be sufficient. The issue we are facing is that the COM object (AutoCAD drawing document) does not load correctly or fully. I have verfied this by converting it to a structure and using fieldnames() to get the different fields. A fully loaded object returns a large number of fields, but most times only a fraction is returned.
We need to find a way to loop or wait until the document is loaded and ready before we can proceed with manipulating it. This far, I have not been able to find a suitable solution and any help is wanted.
Br
Fredrik Walka
7 comentarios
Mario Malic
el 8 de Feb. de 2023
Editada: Mario Malic
el 8 de Feb. de 2023
Hey,
I don't use the AutoCAD, but quick search led me to this AcApDocManagerReactor: https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-RefGuide-__MEMBERTYPE_Methods_AcApDocManagerReactor
Under link, see documentCreated method and check if that is what you are looking for. It is actually a notification/event thing, so it probably might not be, but if you dig around (maybe AcApDocument class), I am preety sure you'll find the way.
Balavignesh
el 16 de Mzo. de 2023
Hi Fredrik Walka,
As per my understanding, you would like to synchronize loading of document and have the main script wait for the read operation to complete.
To better assist you with the issue you are facing, it would be helpful if you could share your code or share the command you are using to load the document.
Fredrik Walka
el 16 de Ag. de 2023
Editada: Fredrik Walka
el 24 de Ag. de 2023
Mario Malic
el 24 de Ag. de 2023
We can't really write something sensible on this. I would suggest you to avoid using struct on objects as this may expose their hidden members that are not supposed to be public, use methods and properties instead. I would also verify that variables/object that you are showing is of the same type with class.
Fredrik Walka
el 24 de Ag. de 2023
Editada: Fredrik Walka
el 24 de Ag. de 2023
Mario Malic
el 25 de Ag. de 2023
One thing you can try is to simply set a pause for several seconds and see if the properties are added after this time. Of course, it's not a great solution but it could reveal if what you are doing is right and document is opening in a corect way.
There is some info here https://forums.autodesk.com/t5/net/how-to-determine-when-a-document-is-completely-loaded/td-p/2684614 about the EndOpen event which could be a way to solve this.
Fredrik Walka
el 25 de Ag. de 2023
Respuestas (0)
Categorías
Más información sobre Use COM Objects in MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
