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

Hi,

 

try this rule:

Dim part As PartDocument = ThisApplication.ActiveDocument
Dim comp As PartComponentDefinition = part.ComponentDefinition
Dim squareEdges As Integer = 4
Dim roundEdge As Integer = 1
Dim areaList As New ArrayList
Dim oArea As Double
Dim oEdge1 As Edge, oEdge2 As Edge
Dim mt As MeasureTools = ThisApplication.MeasureTools
Dim length1 As Double, length2 As Double

For Each oFace As Face In comp.SurfaceBodies.Item(1).Faces
	areaList.Add(oFace.Evaluator.Area & "=" & oFace.TransientKey)
Next
areaList.Sort()
Dim oSplit() As String = Split(areaList.Item(areaList.Count-1), "=")
For Each oFace As Face In comp.SurfaceBodies.Item(1).Faces
	If oFace.TransientKey = oSplit(1) Then
		If oFace.Edges.Count = roundEdge Then
			MessageBox.Show("Part is round.")
			Exit Sub
		ElseIf oFace.Edges.Count = squareEdges Then
			oEdge1 = oFace.Edges.Item(1)
			oEdge2 = oFace.Edges.Item(2)
			length1 = Round(mt.GetMinimumDistance(oEdge1.StartVertex, oEdge1.StopVertex), 3)
			length2 = Round(mt.GetMinimumDistance(oEdge2.StartVertex, oEdge2.StopVertex), 3)
			If length1 = length2 Then
				MessageBox.Show("Part is square.")
				Exit Sub
			ElseIf Not length1 = length2
				MessageBox.Show("Part is rectangle.")
				Exit Sub
			End If
		Else
			MessageBox.Show("Part with another shape.")
			Exit Sub
		End If
	End If
Next