forked from evereux/pycatia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_008.py
38 lines (26 loc) · 1.14 KB
/
example_008.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
#! /usr/bin/python3.6
"""
Example 8:
Open all CATParts in source directory and save to IGS in target directory.
"""
import os
from pycatia import CATIADocHandler
# make these directories the full pathname.
source_directory = 'tests/cat_files'
target_directory = '__junk__'
# if full paths are supplied above you should not do this.
source_directory = os.path.join(os.getcwd(), source_directory)
target_directory = os.path.join(os.getcwd(), target_directory)
# This loop assumes there are NO sub-directories.
for root, dirs, files in os.walk(source_directory):
for file in files:
# only convert CATParts.
if os.path.splitext(file)[1] == '.CATPart':
# create filename with path.
file_name = os.path.join(source_directory, file)
with CATIADocHandler(file_name) as caa:
document = caa.document
# create the full name of the target file, minus extension.
target_file = os.path.join(target_directory, os.path.splitext(file)[0])
# create the igs file in the __junk__ directory.
document.export_data(target_file, 'igs')