How can I use the API to extract the orientation or surface normal of a face?

How can I use the API to extract the orientation or surface normal of a face?

Anonymous
Not applicable
1,945 Views
3 Replies
Message 1 of 4

How can I use the API to extract the orientation or surface normal of a face?

Anonymous
Not applicable

I would like to compare the orientation of one face of one object to one face of another object. Is this possible?

 

Barring that, is there some way to see if 2 edges lie parallel and/or on one plane. even of there is no predefined workplane?

0 Likes
1,946 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

You can measure angle between two vectors. Here is sample(VBA) to measure angle between two vectors. If you compare faces of two different components in assembly remember to get the directions from face proxies or edge proxies. 

 

Sub MeasureVectorA()

Dim oApp As Inventor.Application
Set oApp = ThisApplication

Dim oV1 As Vector
Set oV1 = oApp.TransientGeometry.CreateVector(1, 0, 0)
Dim oV2 As Vector
Set oV2 = oApp.TransientGeometry.CreateVector(0, 1, 0)
Dim oAngle As Double
oAngle = oV1.AngleTo(oV2)


End Sub

0 Likes
Message 3 of 4

Anonymous
Not applicable

How do I go about doing that last part?

 

Thanks

 

Joe

0 Likes
Message 4 of 4

Anonymous
Not applicable

If you mean the proxies, you need to take the directions from proxies and not the native objects. You will find good introduction from API help in Inventor, it's worth to study if you are not familiar with it. Below is a sample how to do that.

 

Or you mean how to check if edges are parallel? If the angle between vectors is 0 or PI(3.14....) then edges are parallel and there is also straight method for that in api also(see sample below). And you can do the same tricks with edges also (direction vector is found from edgeproxy.geometry.direction)

 

I hope this helps.

 

Sub MeasureAngle()

 

Dim oApp As Application
Set oApp = ThisApplication

 

Dim oFaceProxy1 As FaceProxy
Set oFaceProxy1 = oApp.CommandManager.Pick(kAllPlanarEntities, "Pick Face 1")
Dim oPlane1 As Plane
Set oPlane1 = oFaceProxy1.Geometry

 

Dim oFaceProxy2 As FaceProxy
Set oFaceProxy2 = oApp.CommandManager.Pick(kAllPlanarEntities, "Pick Face 2")
Dim oPlane2 As Plane
Set oPlane2 = oFaceProxy2.Geometry

 

Dim oAngle As Double
oAngle = oPlane1.Normal.AngleTo(oPlane2.Normal)

 

Dim blnParallel As Boolean
blnParallel = oPlane1.Normal.IsParallelTo(oPlane2.Normal)


Dim blnPerpendicular As Boolean
blnPerpendicular = oPlane1.Normal.IsPerpendicularTo(oPlane2.Normal)

 

End Sub