Skip to content
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

delete all objects error #45

Open
tetukowski opened this issue Feb 10, 2023 · 0 comments
Open

delete all objects error #45

tetukowski opened this issue Feb 10, 2023 · 0 comments

Comments

@tetukowski
Copy link

tetukowski commented Feb 10, 2023

Hi all,

I get this error when deleting all objects, but it is ok to delete an object individually.

from pyautocad import Autocad, APoint
acad = Autocad(create_if_not_exists=True)

L1 = acad.model.AddLine(APoint(0,0), APoint(500,250))
L2 = acad.model.AddLine(APoint(0,100), APoint(500,600))

for obj in acad.iter_objects():
    obj.Delete()

it returns:

COMError                                  Traceback (most recent call last)
d:\02 Work\02 Projects Piotr\LEARNING\pyautocad_learn\math_array_autocad.py in <cell line: 1>()
----> 1 for obj in acad.iter_objects():
      2     obj.Delete()

~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyautocad\api.py in iter_objects(self, object_name_or_list, block, limit, dont_cast)
    118         count = block.Count
    119         for i in xrange(count):
--> 120             item = block.Item(i)  # it's faster than `for item in block`
    121             if limit and i >= limit:
    122                 return

~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\comtypes\client\lazybind.py in caller(*args)
    180             # DISPATCH_METHOD
    181             def caller(*args):
--> 182                 return self._comobj._invoke(descr.memid, descr.invkind, 0, *args)
    183             try:
    184                 caller.__name__ = name

~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\comtypes\automation.py in _invoke(self, memid, invkind, lcid, *args)
    743             dp.rgvarg = array
    744 
--> 745         self.__com_Invoke(memid, riid_null, lcid, invkind,
    746                           dp, var, None, argerr)
    747         return var._get_value(dynamic=True)

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

I noticed (from AutoCAD) the first object is deleted but not the 2nd one (in the case of two objects).
If I have a lot of objects, some are deleted, and some are not.

It is ok when i do L1.Delete() or L2.Delete(),

Is there anything wrong? Thanks a lot!

system: Windows 10, Python 3.9.13, pyautocad 0.2.0 , AutoCAD 2023

-teko-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant