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

[BUG] __getitem__ and __iter__ accessing wrong .Item methods #195

Closed
mokrueger opened this issue Mar 12, 2024 · 5 comments
Closed

[BUG] __getitem__ and __iter__ accessing wrong .Item methods #195

mokrueger opened this issue Mar 12, 2024 · 5 comments
Assignees

Comments

@mokrueger
Copy link
Contributor

Describe the bug

A bunch of classes access the wrong .item method in the com_objects.
They should be accessing .Item

This leads to errors when using the respective class as iterators (also in for loops) or accessing lists via the bracket operator.

To Reproduce
Try getting an item via bracket operator / using them in a for loop.
e.g.
for r in list(part.relations): ...

Expected behavior
Get the right element.

Screenshot
Example of the wrong code in pycatia/pycatia/knowledge_interfaces/relations.py
image

@mokrueger
Copy link
Contributor Author

Addressed in #196

@evereux
Copy link
Owner

evereux commented Mar 15, 2024

Whilst technically it should be Item I'm failing to reproduce the issue in python 3.10 or 3.11.

This works fine:

from pycatia import catia
from pycatia.mec_mod_interfaces.part_document import PartDocument

caa = catia()
part_document = PartDocument(caa.active_document.com_object)
part = part_document.part

for r in list(part.relations):
    print(r)

@mokrueger
Copy link
Contributor Author

I see. I am using a variant of the Dispatch class which returns a win32com.client.DispatchBaseClass object. Here the attribtues are case sensitive. So that is causing the issues with me.

I'm using the modified com interface provided by Dassault, which is part of the 3DX package.

image

So it shouldn't break anything, if we'd use the "accurate" case sensitivity here. Then I would not have to manually update the files for other pc's when using pycatia.

@evereux
Copy link
Owner

evereux commented Mar 17, 2024

OK. Just wanted to understand why you were having issues as I was surprised this hadn't been raised before.

@evereux
Copy link
Owner

evereux commented Mar 17, 2024

Closing as 0.6.7 now has these changes implemented.

@evereux evereux closed this as completed Mar 17, 2024
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

2 participants