Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Object Polygons

 

Add this script to a "Batch Script" editor (F10) and execute it with Script > Run.

...

Code Block
languagepy
polygonObject = scene.getObject("Torus01")
polygons = polygonObject.getFaces()
 
scene.message("Number of polygons: "+str(len(polygons)))

 

Object Vertices

 

Add this script to a "Batch Script" editor (F10) and execute it with Script > Run.

...

Code Block
languagepy
polygonObject = scene.getObject("Torus01")
vertices = polygonObject.getVertices()
 
scene.message("Number of vertices: "+str(len(vertices)))

 

Polygon Vertices

Add this script to a "Batch Script" editor (F10) and execute it with Script > Run.

Get a torus object's polygons, store them in a list container, and get the three vertices of each polygon. Then, calculate each polygon. Print out their Ids:'s midpoint and place a particle there:

Code Block
languagepy
polygonObject   = scene.getObject("Torus01")
polygons        = polygonObject.getFaces()
vertices        = polygonObject.getVertices()
vertexPositions = Vector.new(0,0,0)
container       = scene.get_PB_Emitter("Container01")
 
for polygon in polygons:
	vertexIndices = polygon.getIndices()
	vertex0       = vertices[vertexIndices[0]]
	vertex1       = vertices[vertexIndices[1]]
	vertex2       = vertices[vertexIndices[2]]
 
	vertex0Pos    = vertex0.getPosition()
	vertex1Pos    = vertex1.getPosition()
	vertex2Pos    = vertex2.getPosition()
 
	vertexPositions = vertex0Pos + vertex1Pos + vertex2Pos
 	vertexPositions.set(vertexPositions.x / 3, vertexPositions.y / 3, vertexPositions.z / 3)
 
	container.addParticle(vertexPositions, Vector.new(0,0,0))