projects links |
Tutorials / UsingPypesProgrammatically
Advanced PypeS TutorialOnce you've gained confidence with the execution of vmtk from the command line you might want to push it a little further and start writing your own Python modules based on PypeS. In this tutorial we are going to guide you through the creation of a Python script implemented as a submodule of PypeS. Using PypeS as parent class for your own scripts offers you the advantage of achieving the same performances of the vmtkscripts that you are already using and makes your own scripts able to easily interact with the rest of the vmtk framework. The module we are about to create has no relevant utility and serves purely as an example. Once completed, the script will display a series of isosurfaces extracted from a same 3D image. Each of the surfaces will represent an increasing value of grey level. The grey levels represented will be limited to a range defined by the user. Let's start by opening a text editor and creating a new file. We can name it as #!/usr/bin/env python import sys from vmtk import pypes from vmtk import vmtkscripts The The next step is the definition of our module. The module will be named as customscript = 'customScript'
class customScript(pypes.pypeScript):
def __init__(self):
pypes.pypeScript.__init__(self)
def Execute(self):
pass
if __name__==_main_:
main = pypes.pypeMain()
main.Arguments = sys.argv
main.Execute()
|