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
[Solution] Exporting BOM with AssemblyConvertor #110
Comments
method appears to require the use of system_service.avaluate
Thanks for the question @deloarts! I've submitted a patch to the development branch for which you can see the link above. This change only affects the assembly_convertor.print method so there's no worry of it affecting anything else. My quick and dirty code that worked: from pycatia import catia
from pycatia.product_structure_interfaces.product import Product
from pycatia.product_structure_interfaces.assembly_convertor import AssemblyConvertor
caa = catia()
document = caa.active_document
product = document.product
product = Product(product.com_object)
bom = product.get_item("BillOfMaterial")
assembly_convertor = AssemblyConvertor(bom.com_object)
details_top = ("Quantity", "Part Number", "Type", "Nomenclature", "Revision")
details_recap = ("Quantity", "Part Number")
assembly_convertor.set_current_format(details_top)
assembly_convertor.set_secondary_format(details_recap)
assembly_convertor.print("XLS", "C:\\Users\\evereux\\Documents\\lalala.xls", product) Thanks for reporting this and going to the effort you have. It's appreciated. I think this is something worth adding to the examples too. |
Just been playing a bit with this and I can reproduce:
I will continue to get the error until I restart CATIA. This isn't a bug in pycatia as far as I know. Whether the bug is in pywin32 or CATIA itself I don't know. error message:
|
I updated my local assembly_converter.py print method according to your changes and got the print method working using your way (by passing the com_object).
Many thanks for pointing me in the right direction, I think I can solve some other issues in my code this way ... For the error: I was able to reproduce the error message
If you're planning on adding this to the examples you may consider adding a warning for using the correct separator, because the error message just says unknown error:
Closing the issue with this. Thanks again! |
Problem
I tried exporting the bill of material as Excel using the get_item method:
This is failing with
AttributeError: 'AnyObject' object has no attribute 'SetCurrentFormat'
since the get_item method doesn't returnAssemblyConvertor
.Solution
I made changes to the any_object.py file by adding the following import
from pycatia.system_interfaces.cat_base_dispatch import CATBaseDispatch
and by adding the following method to the
AnyObject
class:I was following the typehints of the V5automation.chm:
This way i was able to get the
AssemblyConvertor
object and thus the bill of material as Excel:with the
format
being a tuple containing the keywords of the products properties ("PartNumber", "Revision", ...) or the names of user_ref_properties and thepath
is using windows style seperators\\
.Note
Sometimes the export failes with an error (
-2147467259
). I haven't figured out what this error is, because I only encountered it once. After restarting my computer I wasn't able to reproduce the error again. But I don't think this error is related to the pywin32 dispatch, because I also got this error by running the equivalent catvbs:Discussion
I havent't tested it yet, but it should be possible, that this way (returning the
get_item
method asCATBaseDispatch
) may work for all other objects that you try to get with theget_item
method. Do you think this could be added or may this break something else?The text was updated successfully, but these errors were encountered: