Skip to content
Closed
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
15 changes: 10 additions & 5 deletions src/examples/Level1/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 @@ -82,16 +83,23 @@ def step_export_layers_and_colors(event=None):
aisPres = TPrsStd.TPrsStd_AISPresentation().Set(top_label, XCAFPrs.XCAFPrs_Driver().GetID())
aisPres.GetObject().Display(True)
display.FitAll()

# write the stuff to STEP, with layers & colors
WS = XSControl_WorkSession()
writer = STEPCAFControl_Writer( WS.GetHandle(), False )
writer.Transfer(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')
pth = '.'
print 'writing STEP file'
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 All @@ -100,6 +108,3 @@ def exit(event=None):
add_function_to_menu('step ocaf export', step_export_layers_and_colors)
add_function_to_menu('step ocaf export', exit)
start_display()