Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: MjDeck

@MjDeck You are right.

The difference comes from the first half of my 'GetFaceNormal' Function, where I first attempt to get the 'Normal' from the Plane.Normal property, where Face.Geometry is the Plane object.  Apparently that Normal can point in the opposite direction from the 'Normal' we get when using the SurvaceEvaluator.GetNormalAtPoint method.  Not sure why.  But I did do some follow-up testing on the part, due to a suspicion, and found what I was expecting.  For some of the faces of that part, its Face.IsParamReversed property returned a value of True, meaning the face's Normal is pointing inwards (towards interior of material), instead of outwards (away from material).  I guess maybe that can be used as a lesson for how to avoid that unpredictable situation.  Always use the 'Evaluator' tools, instead of the properties of the underlying 'transient geometry' objects (when possible).  When I commented out that whole If...Else...End If statement, and the code within the 'If' half, it works the same as the manual measure tool, as planned.

So, this:

 

Private Function GetFaceNormal(oFace As Inventor.Face) As Inventor.UnitVector
	If TypeOf oFace.Geometry Is Inventor.Plane Then
		Dim oPlane As Inventor.Plane = oFace.Geometry
		Return oPlane.Normal
	Else
		Dim oPt() As Double = {} : Dim oNorm() As Double = {}
		oFace.PointOnFace.GetPointData(oPt)
		oFace.Evaluator.GetNormalAtPoint(oPt, oNorm)
		Return _InvApp.TransientGeometry.CreateUnitVector(oNorm(0), oNorm(1), oNorm(2))
	End If
End Function

 

...had to be simplified back to this:

 

Private Function GetFaceNormal(oFace As Inventor.Face) As Inventor.UnitVector
	Dim oPt() As Double = {} : Dim oNorm() As Double = {}
	oFace.PointOnFace.GetPointData(oPt)
	oFace.Evaluator.GetNormalAtPoint(oPt, oNorm)
	Return _InvApp.TransientGeometry.CreateUnitVector(oNorm(0), oNorm(1), oNorm(2))
End Function

 

I knew that it was possible for the Normal's of faces to be pointing inwards, but still do not understand when or how it happens to be able to predict it.  It seems to me like I usually saw that in bodies / parts that have been created through Mirror type process.

 

Edit:  Here is another version, where it checks that Face.IsParamReversed, and if True, it reverses the polarity of the Normal before returning it.  I only included the Plane.Normal part in the first place, because I thought that it might require less processing or run faster, when compared with the evaluator tools, but have not done specific testing to see if that is true.

Private Function GetFaceNormal(oFace As Inventor.Face) As Inventor.UnitVector
	If TypeOf oFace.Geometry Is Inventor.Plane Then
		Dim oPlane As Inventor.Plane = oFace.Geometry
		If Not oFace.IsParamReversed Then
			Return oPlane.Normal
		Else
			Dim oDir As UnitVector = oPlane.Normal
			oDir.PutUnitVectorData({-oDir.X, -oDir.Y, -oDir.Z}) 'reverse polarity
			Return oDir
		End If
	Else
		Dim oPt() As Double = {} : Dim oNorm() As Double = {}
		oFace.PointOnFace.GetPointData(oPt)
		oFace.Evaluator.GetNormalAtPoint(oPt, oNorm)
		Return _InvApp.TransientGeometry.CreateUnitVector(oNorm(0), oNorm(1), oNorm(2))
	End If
End Function

Wesley Crihfield

EESignature

(Not an Autodesk Employee)