pyautocad COMError: (-2147352567, 'Exception occured.', (None, None, None, 0, None))

46 Views Asked by At

I tried to use pyautocad library to draw a simple circle on an open Autocad file by the code below.

import pyautocad

# Create an instance of AutoCAD
acad = pyautocad.Autocad()

# Define the center point of the circle (x, y coordinates)
center_point = (5, 5)

# Define the radius of the circle
radius = 3

# Draw the circle
circle = acad.model.AddCircle(center_point, radius)

# Display a message
print("Circle drawn successfully.")

However I got the COMError: (-2147352567, 'Exception occured.', (None, None, None, 0, None)) error.

I made a clean uninstall and reinstall of Autocad and reset it to the default settings, I went to the Autocad installation path and enabled the permissions, but I still got the same error. I also disabled the antivirus software, but it did not work either. Could anyone help with the problem?

1

There are 1 best solutions below

0
Grzegorz Świtek On

Try this:

import pyautocad

acad = pyautocad.Autocad()

center_point = pyautocad.aDouble(5, 5)  # ← ← ←

radius = 3

circle = acad.model.AddCircle(center_point, radius)

print("Circle drawn successfully.")