home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Multimedia / k3d-setup-0.7.11.0.exe / share / k3d / scripts / scripted_plugins / demo_pointcounter.py < prev    next >
Encoding:
Text File  |  2008-03-30  |  672 b   |  22 lines

  1. #python
  2.  
  3. # k3d:plugin-class="document"
  4. # k3d:plugin-type="NullOutputScript"
  5. # k3d:plugin-name="PointCounter"
  6. # k3d:plugin-description="Sample plugin script that counts the points in its input mesh"
  7.  
  8. #Small demo script to demonstrate scripted node creation
  9.  
  10. #Add the required user properties
  11. if not hasattr(Node, "input_mesh"):
  12.     Node.create_property("k3d::mesh*", "input_mesh", "Input Mesh", "The mesh that will have its points counted")
  13. if not hasattr(Node, "point_count"):
  14.     Node.create_property("k3d::double_t", "point_count", "Point Count", "Point count for the mesh")
  15.  
  16. mesh = Node.input_mesh
  17. if mesh:
  18.     Node.point_count = len(mesh.points())
  19. else:
  20.     Node.point_count = 0
  21.  
  22.