-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: ActiveDocument #55
Comments
Documents.Open returns a document, what if you send the command with that instance? axDoc = axApp.Documents.Open(file)
axDoc.SendCommand(...)
axDoc.Close(...) |
I found that added 2 time.sleep() statements in between when the doc opens and the PostCommand section.
This is the exception traceback I'm getting:
Translated ("Call rejected by callee") Giving it 2 to 3 seconds after the PostCommand seems to work most of the time on my pc. However this is probably on a case by case basis depending on the file size and the performance of the PC thats running the script. |
maybe you should set the document that you have opened to the 'ActiveDocument' axApp = Ax.getApp()
axApp.ActiveDocument = axApp.Documents.Open('E:/Temp.dwg')
axApp.ActiveDocument.PostCommand(...)
axApp.ZoomExtents()
axApp.ActiveDocument.Close() |
getApp(), as far as i know, isn't a function in this library right? |
Ah sorry, getapp() is from the project I’m working on I don’t know how to use the events from PyAutoCAD, you might get hints from the link above (see createEventObject) |
I'm trying to set up a small script to run a lisp routine over a collection of .dwg files. This is part of a bigger script to export ArcGIS featureclass files into specially formatted .dwg files. The export to CAD function in Arcgis doesn't work well with MLines so I have to run a secondary pass over the generated files to convert the Polylines into MLines.
When running this code:
I sometimes get an error :
It seems to me like the PostCommand function might be trying to execute before the opened document has finished opening. I saw in the AutoCAD ActiveX documentation that AutoCAD does have an EndOpen event ([[https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-1AEC7F00-981A-4517-A830-37CA653D336A]])
Except I have no idea how i could intergrate this in my own code. Can you help me with this?
This error does always occur eventually. Sometimes it does do the first file correctly.
I also tried it with just the ```acad.doc.PostCommand("._zoom _e ._PLtoML N Qsave Close"). Except this can also run into the same issues.
The text was updated successfully, but these errors were encountered: