/src/examples/Level2/DataExchange/export_multi_to_step_colors_layers_ocaf.py

http://pythonocc.googlecode.com/ · Python · 33 lines · 12 code · 3 blank · 18 comment · 0 complexity · f4de499a052b3ea4016243f4940b07c3 MD5 · raw file

  1. ##Copyright 2009 Thomas Paviot (tpaviot@gmail.com)
  2. ##
  3. ##This file is part of pythonOCC.
  4. ##
  5. ##pythonOCC is free software: you can redistribute it and/or modify
  6. ##it under the terms of the GNU Lesser General Public License as published by
  7. ##the Free Software Foundation, either version 3 of the License, or
  8. ##(at your option) any later version.
  9. ##
  10. ##pythonOCC is distributed in the hope that it will be useful,
  11. ##but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ##GNU Lesser General Public License for more details.
  14. ##
  15. ##You should have received a copy of the GNU Lesser General Public License
  16. ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
  17. from OCC.Utils.DataExchange.STEP import StepOCAF_Export
  18. from OCC.BRepPrimAPI import *
  19. # First create a simple shape to export
  20. my_box_shape = BRepPrimAPI_MakeBox(50,50,50).Shape()
  21. my_sphere_shape = BRepPrimAPI_MakeSphere(20).Shape()
  22. # Export to STEP
  23. my_step_exporter = StepOCAF_Export("result_export_multi.stp")
  24. my_step_exporter.set_color(1,0,0) # red
  25. my_step_exporter.set_layer('red')
  26. my_step_exporter.add_shape(my_box_shape)
  27. my_step_exporter.set_color(0,1,0) # green
  28. my_step_exporter.set_layer('green')
  29. my_step_exporter.add_shape(my_sphere_shape)
  30. my_step_exporter.write_file()