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] Instance renaming not working #188

Open
gggstamm opened this issue Jan 17, 2024 · 7 comments
Open

[BUG] Instance renaming not working #188

gggstamm opened this issue Jan 17, 2024 · 7 comments
Assignees

Comments

@gggstamm
Copy link

Describe the bug
when trying to change the "name" it is not taken into account if the Part is in a Component

To Reproduce
Sample of code with snapshot

def bug_pycatia():
    catia_com = catia()
    documents = catia_com.documents

    product_document = documents.add('Product')
    root = Product(product_document.document.Product)
    root.part_number = 'OK1'

    sub_product = root.products.add_new_product('OK2')
    sub_product.part_number = 'OK3'
    sub_product.name = 'OK4'

    sub_product.products.add_components_from_files(i_files_list=((r"E:\CAD_INT\working\exchange_old\Cube.CATPart"),), i_method="All")

    cube = sub_product.products.items()[0]
    cube.part_number = 'OK6'
    cube.name = 'KO_KO_KO'     # this is KO

Expected behavior
the cube instance name should be changed

Screenshots
screenshot of the bad result given
image
Cube.zip

Desktop (please complete the following information):

  • OS: Windows 10
  • CATIA V5 version V5-6R2017]
  • pycatia version 0.6.4

Additional context
no

@evereux
Copy link
Owner

evereux commented Jan 17, 2024

I can reproduce this with my own quick and dirty script.

Have you tested this in VB? pycatia doesn't do anything fancy here so I suspect the fault lies with CATIA V5?

@evereux
Copy link
Owner

evereux commented Jan 17, 2024

So, I recorded a macro to see how CATIA does it in VB and converted that to pycatia. Interestingly this works:

caa = catia()
application = caa.application
document = application.active_document
product_document = document
component_node = Product(product_document.get_item('Product2').com_object)
products = Products(component_node.products.com_object)
sub_part = products.item('LL300010P-101.2')
sub_part.name = 'purple_monkey'

@evereux
Copy link
Owner

evereux commented Jan 17, 2024

Been playing some more. The key here seems to be to use get_item on the ProductDocument to get the component node and not by getting the Products collection from the top Product.

I don't think this is a pycatia bug.

@gggstamm
Copy link
Author

You are right : " The key here seems to be to use get_item"
Then the difficulty is to know what is the name of the item we are looking for (when we come from add_components_from_files)
It is really weird.
In any case, look like it is not a bug on pycatia side, and your comments helped me to get around the issue.
Thanks a lot for your reactivity

@evereux
Copy link
Owner

evereux commented Jan 17, 2024

It's maybe bit hacky but I'm thinking you could maybe use your method to get the name of the instance and use that name with get_item().

It's definitely a bit weird. I'm hoping to have a look at this a bit more soon.

@siddhu2310
Copy link

@gggstamm , Have you resolved your issue ?

@gggstamm
Copy link
Author

gggstamm commented Sep 2, 2024

@gggstamm , Have you resolved your issue ?
@siddhu2310 I do not get your question; evereux gave a working python code with get_item. It is a bad workaround, but a working one!

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

3 participants