Solved: ‘Call was rejected by callee’ in pyautocad

In this blog post, I will discuss an error that occurs while automating tasks in AutoCAD using the pythoncom module.- The pythoncom module is a AutoCAD automatization module in Python. Also, I will provide a solution for the same. The error that I will handle is the “Call was rejected by callee” error.

Cause of the “Call was rejected by callee” error

The main reason for getting this error while working with AutoCAD automation using pythoncom is the speed of call-making. I.e. the speed of making calls.

The subsequent calls that we make to perform certain tasks in AutoCAD are faster than the application can handle.

This eventually throws an ‘Call was rejected by callee’ error.

Solution to the “Call was rejected by callee” error

To solve this issue, we can use the ‘sleep’ method by importing the ‘time’ module into Python.


This method shall be executed after executing certain heavy functions which consume a considerable amount of computer resources while performing tasks. We have to pass parameters as seconds to suspend a process of the current thread for a specified time.

As mentioned in the code above I am suspending the execution for 5 seconds.

Exemplary application to solve the error

The code mentioned below represents a subprocess of a code. I need to turn the viewport on to perform certain tasks on the viewport. But while working with multiple viewports I end up getting the “Call was rejected by callee” error.

To mitigate the same, I am forcing the process to wait for 0.5 seconds and then continue.

def turn_on_viewport(viewport):
    viewport.ViewportOn = True
    print("Viewport On: " + str(viewport.ViewportOn))

For further more blog posts covering AutoCAD automatization please check our other blog posts related to pyautocad and pywin32.

Please leave any questions that you might have as a comment below. Feel free to contact us for any technical assistance. You can do so by using our contact form.

Leave a Reply

2 thoughts on “Solved: ‘Call was rejected by callee’ in pyautocad

  1. Hi!
    Thank you for pyautocad tutorials. They are really useful. Is it possible to manipulate dynamic blocks? insert them in a new file, copy them (that shouldn’t be a problem…I presume the block will have some variable assigned) and maybe change their dynamic properties (distance or visibility)?


    1. Hi Denis,

      Thank you for your kind words. I will cover this topic soon as per your question. In case you have any queries after that, you can always connect with us through our contact form.

      Have a great day!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.