Pythonocc Getting Started
Pythonocc Getting Started
Release 0.16.0
Thomas Paviot
CONTENTS
Introduction
Build / Install
2.1 Build / install from source . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Download / install precompiled binaries . . . . . . . . . . . . . . . . . . . . .
2.3 Conda packages (OSX only) . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
5
6
7
Conclusion
17
19
ii
CONTENTS
CONTENTS
CHAPTER
ONE
INTRODUCTION
This document explains how to get starting with pythonocc: how to build/install, 30 first minutes experience with the package.
pythonocc will allow you to write python scripts that creates and operates 3D BRep geometry.
Chapter 1. Introduction
CHAPTER
TWO
BUILD / INSTALL
The build system uses cmake to configure the project. This is a crossplatform solution: steps
below are the same for Linux, OSX, or Windows platforms.
By default, cmake looks for oce include headers in /usr/local/include/oce and libraries
in /usr/local/include/lib. If these paths dont match your installation, you have to set
OCE_INCLUDE_PATH and OCE_LIB_PATH
If you prefer, you can launche the cmake-gui using the following command
$ cmake-gui ..
If you have many cpus, you can increase the compilation speed with::
$ make -j$ncpus
2.1.3 test
In order to check that everything is ok, run the pythonocc unittest suite:
$ cd ../test
$ python run_tests.py
You can also run the examples avalaible in the pythonocc-core/examples directory.
$
$
$
$
sudo
sudo
sudo
sudo
add-apt-repository ppa:freecad-maintainers/oce-release -y
add-apt-repository ppa:tpaviot/pythonocc -y
apt-get update -q
apt-get install pythonocc-core
OSX
.dmg binary package is available at our github release page.
Environments
Environments are a very important concept, and conda provides more fundamental support
for environments than for instance virtualenv. This is again, related to dependencies. With
conda, mutiple version of pythonocc supporting different version of the OCE library can be
supported. By changing your environment, its easy to upgrade your codebase to a newer version
of PythonOCC while still being able to switch to any older version.
packages at binstar
binstar is a site where you can upload and distribute your own repository of packages (heres
Jelle). Ownership of packages can be shared, which is great for working together on supporting
a package for different platforms. Check out available packages by the [maintainer of conda
and binstar](https://binstar.org/asmeurer/_list-packages)
Contribute pythonocc package for your platform
Using conda, you can also compile and upload binaries with others. First install necessary stuff
to build conda packages:
$ conda install conda-build
$ conda install jinja2
To go further
If your interested to learn more about conda, check out the documentation. Youre also encouraged you to see this excellent talk by Aaron Meurer.
CHAPTER
THREE
In this section, you will discover, in less than 30 minutes, a set of features that covers the
following fields: data import from a STEP AP 203 file, modeling a box, perform a boolean
operation (cut), visualize a shape and render in WebGl.
This tutorial is based upon the ipython console: the qt ipython mode allows an interactive session with pythonocc, without worrying about gui/event management/program freeze comming
along.
10
STEP file was successfull. Lets now display the shape in the graphic window.
You should now see a graphic window, empty, with just a rvb triedron at the lower right corner.
Just pass the blocke_engine_shape to the display, and ask for a refresh
>>> display.DisplayShape(block_cylinder_shape, update=True)
You can see the cylinder block shape, in a light orange color.
Using your mouse you can: * left click and move to rotate * right click and move to pan *
middle click (or mouse wheel) and move to zoom in/out.
3.2. Import a standard file and display a shape
11
12
You can also : * type a/b: enable/disable antialiasing * type w/s: switch from wireframe
to shaded representation modes
A lot more things can be customized though.
13
>>>
>>>
>>>
>>>
>>>
>>>
>>>
14
Here we are!
15
Your default webbrowser will display the generated html page: handle the 3D model the same
way you did it in the qt based window.
16
CHAPTER
FOUR
CONCLUSION
There are many many more features available in pythonocc. To go further, here is what you
can do:
go to the /examples folder and run/study/modify what you see,
read the api documentation,
ask questions to pythonocc@googlegroups.com,
check oce.
Please report to tpaviot@gmail.com any comment or suggestion to improve this document.
17
18
Chapter 4. Conclusion
CHAPTER
FIVE
genindex
modindex
search
19