Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions 18 src/addons/Utils/DataExchange/STEP.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.

import os, os.path
import locale
from OCC.TopoDS import *
from OCC.BRep import *
from OCC.STEPControl import *
Expand All @@ -32,7 +33,6 @@
from OCC.TCollection import *
from OCC.XCAFDoc import *
from OCC.TDF import *
#from OCC.TopoDS import *

from OCC import XCAFApp, TDocStd, TCollection, XCAFDoc, BRepPrimAPI, Quantity, TopLoc, gp, TPrsStd, XCAFPrs

Expand All @@ -42,7 +42,6 @@
from OCC.Quantity import *
from OCC.Utils.Topology import Topo
from OCC.TopAbs import *
import os

class STEPImporter(object):
def __init__(self,filename=None):
Expand Down Expand Up @@ -143,13 +142,19 @@ def add_shape(self, aShape):
self._shapes.append(aShape)

def write_file(self):
# workaround for an OCC bug: temporarily changing the locale in order to
# avoid issues when exporting, see:
# http://tracker.dev.opencascade.org/view.php?id=22898
loc = locale.getlocale()
locale.setlocale(locale.LC_ALL, 'C')
for shp in self._shapes:
status = self.stepWriter.Transfer(shp, STEPControl_AsIs )
if status == IFSelect_RetDone:
status = self.stepWriter.Write(self._filename)
else:
return False

# restoring the old locale
locale.setlocale(locale.LC_ALL, loc)
if self.verbose:
self.stepWriter.PrintStatsTransfer()

Expand Down Expand Up @@ -319,9 +324,16 @@ def write_file(self):
WS = XSControl_WorkSession()
writer = STEPCAFControl_Writer( WS.GetHandle(), False )
writer.Transfer(self.h_doc, STEPControl_AsIs)
# workaround for an OCC bug: temporarily changing the locale in order to
# avoid issues when exporting, see:
# http://tracker.dev.opencascade.org/view.php?id=22898
loc = locale.getlocale()
locale.setlocale(locale.LC_ALL, 'C')
print 'writing STEP file'
status = writer.Write(self.filename)
print 'status:', status
# restoring the old locale
locale.setlocale(locale.LC_ALL, loc)

def TestImport():
"""
Expand Down
9 changes: 9 additions & 0 deletions 9 src/examples/OCAF/step_export.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import locale
from OCC.XCAFApp import *
from OCC.STEPCAFControl import *
from OCC.TDocStd import *
Expand Down Expand Up @@ -89,9 +90,17 @@ def step_export_layers_and_colors(event=None):
writer.Transfer(h_doc, STEPControl_AsIs)
pth = '.'
print 'writing STEP file'
# workaround for an OCC bug: temporarily changing the locale in order to
# avoid issues when exporting, see:
# http://tracker.dev.opencascade.org/view.php?id=22898
loc = locale.getlocale()
locale.setlocale(locale.LC_ALL, 'C')
status = writer.Write(os.path.join(pth, 'step_layers_colors.step'))
print 'status:', status

# restoring the old locale
locale.setlocale(locale.LC_ALL, loc)

def exit(event=None):
sys.exit()

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.