How to find polygon normal
The following python example illustrates how to access the polygon normal from a component selection. Information on polygon normals are accessed using the Geometry2D object for polygons.
def main():
subcomponent = Application.Selection(0).SubComponent
obj = subcomponent.Parent3DObject
polgon_indices = subcomponent.componentcollection.indexarray
Application.LogMessage( Application.ClassName(obj) )
for index in polgon_indices :
v3 = GetPolygonNormal( obj, index )
Application.LogMessage( "polygon["+str(index)+"].normal" + str(v3.Get2()) )
# return Polygon Normal (accessed from Geometry2D object).
# when you have the 3d object and the polygon index
def GetPolygonNormal( obj, index ) :
v3 = XSIMath.CreateVector3()
obj.obj.Geometry2D.Normal(index,v3)
return v3
# return Polygon Normal (accessed from Geometry2D object).
# when you have the PolygonFace
def GetPolygonNormal2( in_poly, index ) :
normal = XSIMath.CreateVector3()
colitem = XSIFactory.CreateObject("XSI.CollectionItem")
colitem.Value = in_poly.parent.parent
colitem.Obj.Geometry2D.Normal(in_poly.Index,normal)
return normal
main()
Notes
- Getting Polygon Normals (http://community.softimage.com/blog.php?b=37)
This page was last modified 12:09, 13 May 2008.
This page has been accessed 9167 times.

