Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Obtain the angle between faces

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
865966724
454 Views, 5 Replies

Obtain the angle between faces

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 平面”)

 

5 REPLIES 5
Message 2 of 6
WCrihfield
in reply to: 865966724

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)

Message 3 of 6
865966724
in reply to: WCrihfield

@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

Message 4 of 6
abdullah_elq
in reply to: 865966724

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
Message 5 of 6
865966724
in reply to: abdullah_elq

That was an outstanding answer! You really hit the nail on the head
Message 6 of 6
865966724
in reply to: 865966724

😀

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report