Python Helper App
|
IntroductionThis tutorial provides an explanation of how spheres can be rendered at the vertices of a polymesh by the use of a so-called "helper app" written in python.
The Python Code
The technique shown in this tutorial uses two supporting python scripts: /Users/user_name/Documents/maya/scripts/shape_utils.py /Users/user_name/Documents/maya/scripts/proc_data.py /Users/user_name/Documents/maya/projects/helper_demo/place_spheres.py Using the Scripts in Maya
Assuming a project directory called "helper_demo" has been set in Maya, create a simple polymesh
object such as a torus.
From the
Parent the RenderManProgram node to the polymesh.
|
Adding an Interface
This section demonstrates how custom attributes should be
added to the
In the outliner select the
In the Attribute Editor for the
Create a float attribute named "
Connecting the Interface
A small python script will be used to update the RenderManProgramShape |
import rfm2.api.strings as apistr; import proc_data; proc_data.PlaceSpheres(apistr.expand_string("<shape>"))
Note the code must be pasted as a |
Use the browse button of the
When the scene is rendered the line of code in the How much text can be passed to a Helper App?
The motivation for implementing the technique of rendering spheres, or
any geometry, at the vertices of a polymesh was to see how much text
could be passed to a python helper app as well as to determine the
efficiency of the technique. For the torus shown above here
is a print-out of the "data" string consisting of 1200 coordinates. Python seems to handle the transfer of the
data string very well even when passing 30,000 coordinates.
0.03 1200 0.494 0.0 -0.078 0.476 0.0 -0.155 0.446 0.0 -0.227 0.405 0.0 -0.294 0.354 0.0 -0.354 0.294 0.0 -0.405 0.227 0.0 -0.446 0.155 0.0 -0.476 0.078 0.0 -0.494 0.0 0.0 -0.5 -0.078 0.0 -0.494 -0.155 0.0 -0.476 -0.227 0.0 -0.446 -0.294 0.0 -0.405 -0.354 0.0 -0.354 -0.405 0.0 -0.294 -0.446 0.0 -0.227 -0.476 0.0 -0.155 -0.494 0.0 -0.078 -0.5 0.0 -0.0 -0.494 0.0 0.078 -0.476 0.0 0.155 -0.446 0.0 0.227 -0.405 0.0 0.294 -0.354 0.0 0.354 -0.294 0.0 0.405 -0.227 0.0 0.446 -0.155 0.0 0.476 -0.078 0.0 0.494 -0.0 0.0 0.5 0.078 0.0 0.494 0.155 0.0 0.476 0.227 0.0 0.446 0.294 0.0 0.405 0.354 0.0 0.354 0.405 0.0 0.294 0.446 0.0 0.227 0.476 0.0 0.155 0.494 0.0 0.078 0.5 0.0 0.0 0.588 0.294 -0.093 0.566 0.294 -0.184 0.531 0.294 -0.27 0.482 0.294 -0.35 0.421 0.294 -0.421 0.35 0.294 -0.482 0.27 0.294 -0.531 0.184 0.294 -0.566 0.093 0.294 -0.588 0.0 0.294 -0.595 -0.093 0.294 -0.588 -0.184 0.294 -0.566 -0.27 0.294 -0.531 -0.35 0.294 -0.482 -0.421 0.294 -0.421 -0.482 0.294 -0.35 -0.531 0.294 -0.27 -0.566 0.294 -0.184 -0.588 0.294 -0.093 -0.595 0.294 -0.0 -0.588 0.294 0.093 -0.566 0.294 0.184 -0.531 0.294 0.27 -0.482 0.294 0.35 -0.421 0.294 0.421 -0.35 0.294 0.482 -0.27 0.294 0.531 -0.184 0.294 0.566 -0.093 0.294 0.588 -0.0 0.294 0.595 0.093 0.294 0.588 0.184 0.294 0.566 0.27 0.294 0.531 0.35 0.294 0.482 0.421 0.294 0.421 0.482 0.294 0.35 0.531 0.294 0.27 0.566 0.294 0.184 0.588 0.294 0.093 0.595 0.294 0.0 0.835 0.476 -0.132 0.804 0.476 -0.261 0.753 0.476 -0.384 0.684 0.476 -0.497 0.598 0.476 -0.598 0.497 0.476 -0.684 0.384 0.476 -0.753 0.261 0.476 -0.804 0.132 0.476 -0.835 0.0 0.476 -0.845 -0.132 0.476 -0.835 -0.261 0.476 -0.804 -0.384 0.476 -0.753 -0.497 0.476 -0.684 -0.598 0.476 -0.598 -0.684 0.476 -0.497 -0.753 0.476 -0.384 -0.804 0.476 -0.261 -0.835 0.476 -0.132 -0.845 0.476 -0.0 -0.835 0.963 0.132 -0.804 0.963 0.261 -0.753 0.963 0.384 -0.684 0.963 0.497 -0.598 0.963 0.598 -0.497 0.963 0.684 -0.384 0.476 0.753 -0.261 0.476 0.804 -0.132 0.476 0.835 -0.0 0.476 0.845 0.132 0.476 0.835 0.261 0.476 0.804 0.384 0.476 0.753 0.497 0.476 0.684 0.598 0.476 0.598 0.684 0.476 0.497 0.753 0.476 0.384 0.804 0.476 0.261 0.835 0.476 0.132 0.845 0.476 0.0 1.448 0.787 -0.181 1.098 0.476 -0.357 1.029 0.476 -0.524 0.934 0.476 -0.679 0.816 0.476 -0.816 0.679 0.476 -0.934 0.524 0.476 -1.029 0.357 0.476 -1.098 0.181 0.476 -1.14 0.0 0.476 -1.155 -0.181 0.476 -1.14 -0.357 0.476 -1.098 -0.524 0.476 -1.029 -0.679 0.476 -0.934 -0.816 0.476 -0.816 -0.934 0.476 -0.679 -1.029 0.476 -0.524 -1.098 0.476 -0.357 -1.14 0.963 -0.181 -1.155 0.963 -0.0 -1.14 0.963 0.181 -1.098 0.963 0.357 -1.029 0.963 0.524 -0.934 0.963 0.679 -0.816 0.963 0.816 -0.679 0.476 0.934 -0.524 0.476 1.029 -0.357 0.476 1.098 -0.181 0.476 1.14 -0.0 0.476 1.155 0.181 0.476 1.14 0.357 0.476 1.098 0.524 0.476 1.029 0.679 0.476 0.934 0.816 0.476 0.816 0.934 0.476 0.679 1.029 0.476 0.524 1.098 0.476 0.357 1.14 0.476 0.181 1.155 0.476 0.0 1.695 0.605 -0.22 1.644 0.605 -0.434 1.251 0.294 -0.638 1.136 0.294 -0.826 0.993 0.294 -0.993 0.826 0.294 -1.136 0.638 0.294 -1.251 0.434 0.294 -1.336 0.22 0.294 -1.387 0.0 0.294 -1.405 -0.22 0.294 -1.387 -0.434 0.294 -1.336 -0.638 0.294 -1.251 -0.826 0.294 -1.136 -0.993 0.294 -0.993 -1.136 0.294 -0.826 -1.251 0.294 -0.638 -1.336 0.782 -0.434 -1.387 0.782 -0.22 -1.405 0.782 -0.0 -1.387 0.782 0.22 -1.336 0.782 0.434 -1.251 0.782 0.638 -1.136 0.294 0.826 -0.993 0.294 0.993 -0.826 0.294 1.136 -0.638 0.294 1.251 -0.434 0.294 1.336 -0.22 0.294 1.387 -0.0 0.294 1.405 0.22 0.294 1.387 0.434 0.294 1.336 0.638 0.294 1.251 0.826 0.294 1.136 0.993 0.294 0.993 1.136 0.294 0.826 1.251 0.294 0.638 1.644 0.605 0.434 1.695 0.605 0.22 1.713 0.605 0.0 1.79 0.311 -0.235 1.735 0.311 -0.464 1.645 0.311 -0.681 1.522 0.311 -0.882 1.061 0.0 -1.061 0.882 0.0 -1.214 0.681 0.0 -1.337 0.464 0.0 -1.427 0.235 0.0 -1.482 0.0 0.0 -1.5 -0.235 0.0 -1.482 -0.464 0.0 -1.427 -0.681 0.0 -1.337 -0.882 0.0 -1.214 -1.061 0.0 -1.061 -1.214 0.0 -0.882 -1.337 0.488 -0.681 -1.427 0.488 -0.464 -1.482 0.488 -0.235 -1.5 0.488 -0.0 -1.482 0.488 0.235 -1.427 0.488 0.464 -1.337 0.0 0.681 -1.214 0.0 0.882 -1.061 0.0 1.061 -0.882 0.0 1.214 -0.681 0.0 1.337 -0.464 0.0 1.427 -0.235 0.0 1.482 -0.0 0.0 1.5 0.235 0.0 1.482 0.464 0.0 1.427 0.681 0.0 1.337 0.882 0.0 1.214 1.061 0.0 1.061 1.214 0.0 0.882 1.337 0.0 0.681 1.735 0.311 0.464 1.79 0.311 0.235 1.808 0.311 0.0 1.695 0.018 -0.22 1.644 0.018 -0.434 1.56 0.018 -0.638 1.444 0.018 -0.826 1.301 0.018 -0.993 0.826 -0.294 -1.136 0.638 -0.294 -1.251 0.434 -0.294 -1.336 0.22 -0.294 -1.387 0.0 -0.294 -1.405 -0.22 -0.294 -1.387 -0.434 -0.294 -1.336 -0.638 -0.294 -1.251 -0.826 -0.294 -1.136 -0.993 -0.294 -0.993 -1.136 -0.294 -0.826 -1.251 -0.294 -0.638 -1.336 0.194 -0.434 -1.387 0.194 -0.22 -1.405 0.194 -0.0 -1.387 -0.294 0.22 -1.336 -0.294 0.434 -1.251 -0.294 0.638 -1.136 -0.294 0.826 -0.993 -0.294 0.993 -0.826 -0.294 1.136 -0.638 -0.294 1.251 -0.434 -0.294 1.336 -0.22 -0.294 1.387 -0.0 -0.294 1.405 0.22 -0.294 1.387 0.434 -0.294 1.336 0.638 -0.294 1.251 0.826 -0.294 1.136 0.993 -0.294 0.993 1.136 -0.294 0.826 1.251 -0.294 0.638 1.336 -0.294 0.434 1.695 0.018 0.22 1.713 0.018 0.0 1.14 -0.476 -0.181 1.098 -0.476 -0.357 1.029 -0.476 -0.524 0.934 -0.476 -0.679 0.816 -0.476 -0.816 0.679 -0.476 -0.934 0.524 -0.476 -1.029 0.357 -0.476 -1.098 0.181 -0.476 -1.14 0.0 -0.476 -1.155 -0.181 -0.476 -1.14 -0.357 -0.476 -1.098 -0.524 -0.476 -1.029 -0.679 -0.476 -0.934 -0.816 -0.476 -0.816 -0.934 -0.476 -0.679 -1.029 -0.476 -0.524 -1.098 -0.476 -0.357 -1.14 -0.476 -0.181 -1.155 -0.476 -0.0 -1.14 -0.476 0.181 -1.098 -0.476 0.357 -1.029 -0.476 0.524 -0.934 -0.476 0.679 -0.816 -0.476 0.816 -0.679 -0.476 0.934 -0.524 -0.476 1.029 -0.357 -0.476 1.098 -0.181 -0.476 1.14 -0.0 -0.476 1.155 0.181 -0.476 1.14 0.357 -0.476 1.098 0.524 -0.476 1.029 0.679 -0.476 0.934 0.816 -0.476 0.816 0.934 -0.476 0.679 1.029 -0.476 0.524 1.098 -0.476 0.357 1.14 -0.476 0.181 1.155 -0.476 0.0 0.835 -0.476 -0.132 0.804 -0.476 -0.261 0.753 -0.476 -0.384 0.684 -0.476 -0.497 0.598 -0.476 -0.598 0.497 -0.476 -0.684 0.384 -0.476 -0.753 0.261 -0.476 -0.804 0.132 -0.476 -0.835 0.0 -0.476 -0.845 -0.132 -0.476 -0.835 -0.261 -0.476 -0.804 -0.384 -0.476 -0.753 -0.497 -0.476 -0.684 -0.598 -0.476 -0.598 -0.684 -0.476 -0.497 -0.753 -0.476 -0.384 -0.804 -0.476 -0.261 -0.835 -0.476 -0.132 -0.845 -0.476 -0.0 -0.835 -0.476 0.132 -0.804 -0.476 0.261 -0.753 -0.476 0.384 -0.684 -0.476 0.497 -0.598 -0.476 0.598 -0.497 -0.476 0.684 -0.384 -0.476 0.753 -0.261 -0.476 0.804 -0.132 -0.476 0.835 -0.0 -0.476 0.845 0.132 -0.476 0.835 0.261 -0.476 0.804 0.384 -0.476 0.753 0.497 -0.476 0.684 0.598 -0.476 0.598 0.684 -0.476 0.497 0.753 -0.476 0.384 0.804 -0.476 0.261 0.835 -0.476 0.132 0.845 -0.476 0.0 0.588 -0.294 -0.093 0.566 -0.294 -0.184 0.531 -0.294 -0.27 0.482 -0.294 -0.35 0.421 -0.294 -0.421 0.35 -0.294 -0.482 0.27 -0.294 -0.531 0.184 -0.294 -0.566 0.093 -0.294 -0.588 0.0 -0.294 -0.595 -0.093 -0.294 -0.588 -0.184 -0.294 -0.566 -0.27 -0.294 -0.531 -0.35 -0.294 -0.482 -0.421 -0.294 -0.421 -0.482 -0.294 -0.35 -0.531 -0.294 -0.27 -0.566 -0.294 -0.184 -0.588 -0.294 -0.093 -0.595 -0.294 -0.0 -0.588 -0.294 0.093 -0.566 -0.294 0.184 -0.531 -0.294 0.27 -0.482 -0.294 0.35 -0.421 -0.294 0.421 -0.35 -0.294 0.482 -0.27 -0.294 0.531 -0.184 -0.294 0.566 -0.093 -0.294 0.588 -0.0 -0.294 0.595 0.093 -0.294 0.588 0.184 -0.294 0.566 0.27 -0.294 0.531 0.35 -0.294 0.482 0.421 -0.294 0.421 0.482 -0.294 0.35 0.531 -0.294 0.27 0.566 -0.294 0.184 0.588 -0.294 0.093 0.595 -0.294 0.0 |
© 2002- Malcolm Kesson. All rights reserved.