forked from evereux/pycatia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_003.py
39 lines (25 loc) · 942 Bytes
/
example_003.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/python3.6
"""
Example 3:
Find all points in the CATPart and print to console -> and export to csv.
"""
import csv
from pycatia import catia
caa = catia()
documents = caa.documents
documents.open(r'tests/cat_files/part_measurable.CATPart')
document = caa.active_document
spa_workbench = document.spa_workbench()
part = document.part()
selected = document.search_for_items(['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_from_object(selection)
measurable = spa_workbench.get_measurable(reference)
# print to console.
print(selection.name, measurable.get_point())
x, y, z = measurable.get_point()
csv_writer.writerow([selection.name, x, y, z])