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()
	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
	return normal


This page was last modified 12:09, 13 May 2008.
This page has been accessed 11689 times.

© Copyright 2009 Autodesk Inc. All Rights Reserved. Privacy Policy | Legal Notices and Trademarks | Report Piracy