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

Obtain the angle between faces

865966724
Contributor

Obtain the angle between faces

865966724
Contributor
Contributor

I need help. I am obtaining the angle between two faces, as shown in the figure. I can use the defined face and yz plane to determine the angle. What about the other face? If I don't define how to obtain the angle between these two faces.

 

My ultimate goal is to incorporate this perspective into the user parameters created. If I don't define it in advance, is there any way to distinguish between left and right.

MessageBox.Show(Measure.Angle(“面0”,“YZ 平面”), “Title”) R=Measure.Angle(“面0”,“YZ 平面”)

 

0 Likes
Reply
Accepted solutions (1)
718 Views
5 Replies
Replies (5)

WCrihfield
Mentor
Mentor

Hi @865966724.  I noticed that you have only assigned a name to one of the two faces.  Why not assign a name to the other face that you want to measure the angle to?  If you did that, then you could supply the name that you assigned to that second face instead of the name of the work plane.  I did that within your file, and that worked fine.  But there are some language differences between my installation of Inventor and yours, so I am not sure if this attached copy of your file will be usable or not.  I am using Inventor 2024.0.1, so if you are using an older version, you may not be able to open it properly.  I named the other angled face "Face2".  Then I created two more iLogic rules within that part that both seemed to work OK for me.  However, the original one returns the value in document units, while the third iLogic rule will return the value in database units.

Edit:  Just in case you can not open the file, below are the two other iLogic rules that I created, after assigning that name to the other face.

 

MessageBox.Show(Measure.Angle("面0","Face2"), "Title")
R = Measure.Angle("面0","Face2”)
Dim oNEs As NamedEntities = iLogicVb.Automation.GetNamedEntities(ThisDoc.Document)
Dim oFace1 As Face = oNEs.FindEntity("面0")
Dim oFace2 As Face = oNEs.FindEntity("Face2")
Dim dAngle As Double = ThisApplication.MeasureTools.GetAngle(oFace1, oFace2)
MsgBox("Angle = " & dAngle, vbInformation, "Angle")

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

865966724
Contributor
Contributor

@WCrihfieldThank you for responding. I will provide a more detailed explanation for the question I raised. What I mean is whether it is possible to measure the angles of two faces without manually specifying the name.The reason why I raised this question is that I have many parts that have been cut at angles like this without specifying a nameI need them to measure the angle on one side. What I want is to measure the angle with the yz plane in the original coordinate system, on the left or on the right.1.jpg2.jpg

0 Likes

abdullah_elq
Advocate
Advocate
Accepted solution

Let me know if this works for you:

Dim oMeasureTools As MeasureTools = ThisApplication.MeasureTools
Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPartCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oSurfaceBody As SurfaceBody = oPartCompDef.SurfaceBodies(1)
Dim YZPlane As WorkPlane = oPartCompDef.WorkPlanes("YZ Plane")

For Each oFace As Face In oSurfaceBody.Faces
	If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then
		Dim FaceAngleRadians As Double = oMeasureTools.GetAngle(YZPlane, oFace)
		Dim FaceAngleDegrees As Double = FaceAngleRadians * 180 / PI
		Dim FaceLocation As String
		
		If Not EqualWithinTolerance(FaceAngleDegrees, 90, 0.001) Then
			
			If oFace.PointOnFace.X >  0 Then
				FaceLocation = "Right"
			Else
				FaceLocation = "Left"
			End If
			
			MessageBox.Show(String.Concat(FaceLocation, " face is at an angle of ", FaceAngleDegrees))

		End If
		
	End If
Next

865966724
Contributor
Contributor
That was an outstanding answer! You really hit the nail on the head

865966724
Contributor
Contributor

😀

0 Likes