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.

time.sleep(5)

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))
    time.sleep(0.5)

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.

You May Also Like

Leave a Reply

4 comments

Denis Digula says:

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)?
Thanks!

Denis

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!

T-Br says:

Hello,Tammy.Thank you very much. What i want to ask is how can i add Donut and leader line using pyautocad. acd.model.AddDonut(p1,outer diameter,inner diameter).

T-Br says:

Hello,Tammy.Thank you very much. What i want to ask is how can i add Donut ,hatch and leader line using pyautocad(not paywin32). acd.model.AddDonut(p1,outer diameter,inner diameter) is not working.

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.