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
33import sys
34from pathlib import Path
35import os
36
37
38import cadexchanger.CadExCore as cadex
39
40sys.path.append(os.path.abspath(os.path.dirname(Path(__file__).resolve()) + r"/../../"))
41import cadex_license as license
42import cadexchanger.CadExSTEP as step
43import cadexchanger.CadExJT as jt
44import cadexchanger.CadExOBJ as obj
45
46
47def main(theSource: str, theDest: str):
48 aKey = license.Value()
49
50 if not cadex.LicenseManager.Activate(aKey):
51 print("Failed to activate CAD Exchanger license.")
52 return 1
53
55
56 print("Conversion started...")
57
59
60
61 aSTEPReaderParams = step.STEP_ReaderParameters()
62 aSTEPReaderParams.SetPreferredBRepRepresentationType(step.STEP_ReaderParameters.AdvancedBRep)
63 aReader.SetReaderParameters(aSTEPReaderParams)
64
65 aJTReaderParams = jt.JT_ReaderParameters()
66 aJTReaderParams.SetLayerConversionMode(jt.JT_ReaderParameters.LayerFilter)
67 aReader.SetReaderParameters(aJTReaderParams)
68
69
71 print("Failed to open and convert the file " + theSource)
72 return 1
73
75
76 anOBJParams = obj.OBJ_WriterParameters()
77
78 anOBJParams.SetLengthUnit(cadex.Base_LU_Centimeters)
79 anOBJParams.SetToGenerateMtlFile(True)
80 aWriter.SetWriterParameters(anOBJParams)
81
82 aJTParams = jt.JT_WriterParameters()
83 aJTParams.SetFileSplitMode(jt.JT_WriterParameters.PerPart)
84 aWriter.SetWriterParameters(aJTParams)
85
87 try:
88
90 print("Failed to convert and write the file to specified format " + theDest)
91 return 1
93 print(anEx.What())
94 return 1
95
96 print("Completed")
97 return 0
98
99if __name__ == "__main__":
100 if len(sys.argv) != 3:
101 print(" <input_file> is a name of the STEP file to be read")
102 print(" <output_file> is a name of the JT file to Save() the model")
103 sys.exit(1)
104
105 aSource = os.path.abspath(sys.argv[1])
106 aDest = os.path.abspath(sys.argv[2])
107
108 sys.exit(main(aSource, aDest))
Abstract base class for exceptions thrown from CAD Exchanger.
Definition: Base_Exception.hxx:34
static const std::shared_ptr< Base_Settings > & Default()
Returns global settings object.
Definition: Base_Settings.cxx:541
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition: Base_UTF16String.hxx:34
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
Writes any format that CAD Exchanger can export.
Definition: ModelData_ModelWriter.hxx:33