How to wait for AutoCAD document to finish loading before proceeding in code
이전 댓글 표시
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
Mario Malic
2023년 2월 8일
편집: Mario Malic
2023년 2월 8일
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
2023년 3월 16일
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
2023년 8월 16일
편집: Fredrik Walka
2023년 8월 24일
Mario Malic
2023년 8월 24일
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
2023년 8월 24일
편집: Fredrik Walka
2023년 8월 24일
Mario Malic
2023년 8월 25일
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
2023년 8월 25일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
