pycatia icon indicating copy to clipboard operation
pycatia copied to clipboard

Add method 'add_new_symmetry_2'

Open deloarts opened this issue 3 years ago • 1 comments

I added the add_new_symmetry_2 method to the shape_factory module. This method is not documented in my V5 Automation.chm help file, but it exists.

There is only one reference to this method: image

I added the docstring by hand, please check for correctness. Maybe this method is documented in a newer version of the help file.

This method is needed for mirroring a part, I tested this with the following code:


from pycatia import catia
from pycatia.hybrid_shape_interfaces.hybrid_shape_symmetry import \
    HybridShapeSymmetry
from pycatia.mec_mod_interfaces.part import Part
from pycatia.mec_mod_interfaces.part_document import PartDocument


def create_symmetry_of_main_body_zx(part: Part) -> HybridShapeSymmetry:
    part.in_work_object = part.main_body
    mirror_reference = part.create_reference_from_object(part.origin_elements.plane_zx)
    shape_factory = part.shape_factory
    mirror_symmetry = shape_factory.add_new_symmetry_2(mirror_reference)
    mirror_symmetry.hybrid_shape
    part.in_work_object = part.main_body
    part.update_object(part.main_body)
    return mirror_symmetry


caa = catia()
documents = caa.documents
doc = PartDocument(caa.active_document.com_object)
create_symmetry_of_main_body_zx(doc.part)

deloarts avatar Oct 10 '22 13:10 deloarts

Add example on how to mirror a body using the add_new_symmetry_2 method to the PR.

deloarts avatar Oct 11 '22 07:10 deloarts

Thanks again for your work here.

This method is not documented in my V5 Automation.chm help file, but it exists.

I see the same in my chm file which is from R28. I suspect Dassault have messed something up their end which is why it doesn't exist in the documentation. The formatting of the automation chm files is somewhat buggy in places and caused me many problems when generating pycatia source files.

I've now merged these changes into my developement branch.

I made a couple of changes:

1

from pycatia.hybrid_shape_interfaces.hybrid_shape_symmetry import \
    HybridShapeSymmetry

is now

from pycatia.hybrid_shape_interfaces.hybrid_shape_symmetry import HybridShapeSymmetry

pycatia generally has a 120 character limit, not < 80.

2

CAA V5 Visual Basic Help (2020-07-06 14:02:20.222384))

is now

CAA V5 Visual Basic Help - Manually created. (2022-10-10)

2020-07-06 14:02:20.222384: This time stamp tells me when I ran my script to generate the python code from the chm files. This is how the majority of the current iteration of pycatia was built. At the time I figured if I updated / fixed bugs in the script I wanted to know what was generated / when so I could more easily replace / update existing code.

Anyway, since this was manually generally I decided to make the above change.

evereux avatar Nov 14 '22 12:11 evereux

pycatia generally has a 120 character limit, not < 80.

Good to know, I'll change my formatter settings.

And thanks for merging 🤘🏼

deloarts avatar Nov 14 '22 13:11 deloarts