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

Help with iLogic error - Plane.isParallelto/iscoplanarto

xenocatalyst
Advocate

Help with iLogic error - Plane.isParallelto/iscoplanarto

xenocatalyst
Advocate
Advocate

Hi,

 

I am writing some automation code in iLogic and am having an issue with using IsCoplanarto and IsParallelto 

These methods create an error when used with face or face.geometry ie.: 

oPlane1.IsParallelTo(oFace.Geometry)  or oPlane1.IsCoplanarTo(oFace.Geometry)

The code seems to work fine if i use "On Error Resume Next" or "Try Catch" to handle the error, but i will be needing to debug in the future so i would like to find a way that will not generate an error.

 

Attached is a file with 2 rules, one with error handling on to show how it should work, the other with error handling off to show the error.

 

here is my code

 

'On Error Resume Next

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPlane1 As Plane = Nothing
Dim oPlane2 As Plane = Nothing

Dim oFaces As Faces = oDoc.ComponentDefinition.SurfaceBodies.Item(1).Faces 'gets too many results but works, using worksurfaces doesnt give me the correct result
MessageBox.Show(oFaces.Count.ToString, "Check No. of faces in Surface body")

Dim oFace1 As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select a face")
Dim oFace2 As Face = Nothing
oPlane1 = oFace1.Geometry	

For Each oFace As Face In oFaces	
	If oPlane1.IsCoplanarTo(oFace.Geometry) Then 
	ElseIf oPlane1.IsParallelTo(oFace.Geometry) Then 
			oFace2 = oFace
	End If
Next

DistPoints = ThisApplication.MeasureTools.GetMinimumDistance(oFace1, oFace2)
Distmm = Round(DistPoints * 10).ToString() + "mm Thick"
MessageBox.Show(Distmm, "Title")	

 

0 Likes
Reply
Accepted solutions (1)
284 Views
3 Replies
Replies (3)

A.Acheson
Mentor
Mentor
Accepted solution

Hi @xenocatalyst 

 

If you check the face surface type to ensure it's a plane surface then you should be home and dry. The sample API help page shown here in face.geometry gave me the hint for this

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPlane1 As Plane = Nothing
Dim oPlane2 As Plane = Nothing

Dim oFaces As Faces = oDoc.ComponentDefinition.SurfaceBodies.Item(1).Faces 'gets too many results but works, using worksurfaces doesnt give me the correct result
MessageBox.Show(oFaces.Count.ToString, "Check No. of faces in Surface body")

Dim oFace1 As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select a face")
Dim oFace2 As Face = Nothing
oPlane1 = oFace1.Geometry	

For Each oFace As Face In oFaces

	 If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then
		If oPlane1.IsCoplanarTo(oFace.Geometry) Then 
		ElseIf oPlane1.IsParallelTo(oFace.Geometry) Then 
				oFace2 = oFace
		End If
    End If
	
Next

DistPoints = ThisApplication.MeasureTools.GetMinimumDistance(oFace1, oFace2)
Distmm = Round(DistPoints * 10).ToString() + "mm Thick"
MessageBox.Show(Distmm, "Title")

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes

xenocatalyst
Advocate
Advocate

Thanks for that Alan,

 

That is exactly what I needed.

 

What i take away from this is I was attempting to compare a planar object using a property that was not present in a non planar object, sort of.

A.Acheson
Mentor
Mentor

Well those methods can only accept plane objects for comparison so if you offered anything else then your error occurs. In my test case it was a simple pipe and it was either plane or cylinder surface types.  When the filter is applied then you only have one type. 

You were right to question using on error resume or just a try catch. It gives more understanding to your methods the longer way. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes