def test_get_point(): with CATIADocHandler(measurable_part) as handler: catia = handler.catia document = handler.document part = document.part() spa_workbench = create_spa_workbench(document.document) hybrid_body = part.get_hybrid_body_by_name('Points') point1 = hybrid_body.HybridShapes.Item(1) point1_reference = part.create_reference(point1) point1_measurable = create_measurable(spa_workbench, point1_reference) catia_measurable_point1 = CATIAMeasurable(point1_measurable) point = ( 0.0, 8.0, -4.0, ) catia_point = catia_measurable_point1.get_point(catia) catia_point = round_tuple(catia_point, 6) assert point == catia_point
""" Example 2: Get all the points in the geometrical set 'Points' and print the co-ordinate. """ from pycatia import CATIAApplication from pycatia import CATIAMeasurable from pycatia import create_measurable from pycatia import create_spa_workbench catia = CATIAApplication() documents = catia.documents() documents.open(r'tests\CF_catia_measurable_part.CATPart') document = catia.document() part = document.part() spa_workbench = create_spa_workbench(document.document) hybrid_body = part.get_hybrid_body_by_name('Points') points = part.get_hybrid_shapes_from_hybrid_body(hybrid_body) for point in points: reference = part.create_reference(point) measurable = create_measurable(spa_workbench, reference) point_measurable = CATIAMeasurable(measurable) coordinates = point_measurable.get_point(catia) print(f'{point.name}: {coordinates}')
from pycatia import create_spa_workbench catia = CATIAApplication() documents = catia.documents() documents.open(r'tests\CF_catia_measurable_part.CATPart') document = catia.document() spa_workbench = create_spa_workbench(document.document) part = document.part() selected = document.search_for_items(document, ['Point']) # export the points to a csv file. csv_file_name = '__junk__\\exported_points.csv' with open(csv_file_name, 'w', newline='') as csv_file: csv_writer = csv.writer(csv_file, delimiter=',') for selection in selected: reference = part.create_reference(selection) selection_measurable = create_measurable(spa_workbench, reference) measurable = CATIAMeasurable(selection_measurable) # print to console. print(selection.Name, measurable.get_point(catia)) point_name = selection.Name x, y, z = measurable.get_point(catia) csv_writer.writerow([point_name, x, y, z])