|
18 | 18 | ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
|
20 | 20 | import os, os.path |
| 21 | +import locale |
21 | 22 | from OCC.TopoDS import * |
22 | 23 | from OCC.BRep import * |
23 | 24 | from OCC.STEPControl import * |
|
32 | 33 | from OCC.TCollection import * |
33 | 34 | from OCC.XCAFDoc import * |
34 | 35 | from OCC.TDF import * |
35 | | -#from OCC.TopoDS import * |
36 | 36 |
|
37 | 37 | from OCC import XCAFApp, TDocStd, TCollection, XCAFDoc, BRepPrimAPI, Quantity, TopLoc, gp, TPrsStd, XCAFPrs |
38 | 38 |
|
|
42 | 42 | from OCC.Quantity import * |
43 | 43 | from OCC.Utils.Topology import Topo |
44 | 44 | from OCC.TopAbs import * |
45 | | -import os |
46 | 45 |
|
47 | 46 | class STEPImporter(object): |
48 | 47 | def __init__(self,filename=None): |
@@ -143,13 +142,19 @@ def add_shape(self, aShape): |
143 | 142 | self._shapes.append(aShape) |
144 | 143 |
|
145 | 144 | def write_file(self): |
| 145 | + # workaround for an OCC bug: temporarily changing the locale in order to |
| 146 | + # avoid issues when exporting, see: |
| 147 | + # http://tracker.dev.opencascade.org/view.php?id=22898 |
| 148 | + loc = locale.getlocale() |
| 149 | + locale.setlocale(locale.LC_ALL, 'C') |
146 | 150 | for shp in self._shapes: |
147 | 151 | status = self.stepWriter.Transfer(shp, STEPControl_AsIs ) |
148 | 152 | if status == IFSelect_RetDone: |
149 | 153 | status = self.stepWriter.Write(self._filename) |
150 | 154 | else: |
151 | 155 | return False |
152 | | - |
| 156 | + # restoring the old locale |
| 157 | + locale.setlocale(locale.LC_ALL, loc) |
153 | 158 | if self.verbose: |
154 | 159 | self.stepWriter.PrintStatsTransfer() |
155 | 160 |
|
@@ -319,9 +324,16 @@ def write_file(self): |
319 | 324 | WS = XSControl_WorkSession() |
320 | 325 | writer = STEPCAFControl_Writer( WS.GetHandle(), False ) |
321 | 326 | writer.Transfer(self.h_doc, STEPControl_AsIs) |
| 327 | + # workaround for an OCC bug: temporarily changing the locale in order to |
| 328 | + # avoid issues when exporting, see: |
| 329 | + # http://tracker.dev.opencascade.org/view.php?id=22898 |
| 330 | + loc = locale.getlocale() |
| 331 | + locale.setlocale(locale.LC_ALL, 'C') |
322 | 332 | print 'writing STEP file' |
323 | 333 | status = writer.Write(self.filename) |
324 | 334 | print 'status:', status |
| 335 | + # restoring the old locale |
| 336 | + locale.setlocale(locale.LC_ALL, loc) |
325 | 337 |
|
326 | 338 | def TestImport(): |
327 | 339 | """ |
|
0 commit comments