Check a point is up or down with a plane

Check a point is up or down with a plane

SandmanINV
Advocate Advocate
664 Views
3 Replies
Message 1 of 4

Check a point is up or down with a plane

SandmanINV
Advocate
Advocate

Hello, 

I have a Plane. This Plane through center of mass point.

And I have a Point. How can I check that point is up side or down side of that plane ?

Thank you very much,

0 Likes
Accepted solutions (1)
665 Views
3 Replies
Replies (3)
Message 2 of 4

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @SandmanINV 

I don't know exactly how you define over/under the plane. If its about the Z-position you can use this rule:

Dim oPlane As WorkPlane = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Pick plane.")
Dim oPoint As WorkPoint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPointFilter, "Pick point.")
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oLine As Line = oTG.CreateLine(oPoint.Point, oTG.CreateVector(0, 0, 1))
Dim oIntPoint As Point = oLine.IntersectWithSurface(oPlane.Plane).Item(1)
Select Case oIntPoint.Z
	Case > oPoint.Point.Z
		MsgBox("Point is under plane")
	Case < oPoint.Point.Z
		MsgBox("Point is over plane")
	Case oPoint.Point.Z
		MsgBox("Point is on plane")
End Select

If it's about the planes normal, where over plane means that the point is in positive normal direction from the plane you can use this rule:

Dim oPlane As WorkPlane = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Pick plane.")
Dim oPoint As WorkPoint = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPointFilter, "Pick point.")

Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oLine As Line = oTG.CreateLine(oPoint.Point, oPlane.Plane.Normal.AsVector)

Dim oIntPoint As Point = oLine.IntersectWithSurface(oPlane.Plane).Item(1)

If oIntPoint.IsEqualTo(oPoint.Point)
	MsgBox("Point is on plane")
Else
If oIntPoint.VectorTo(oPoint.Point).AsUnitVector.IsEqualTo(oPlane.Plane.Normal)
	MsgBox("Point is over plane")
Else
	MsgBox("Point is under plane")
End If
End If

 

Message 3 of 4

SandmanINV
Advocate
Advocate

I will code follow your guide number 1. Creating Unit vector to do that. So coool.

Thanh you very much Mr @JhoelForshav 

 

Message 4 of 4

Maxim-CADman77
Advisor
Advisor

@JhoelForshav 
Could you, please, share how can forum user publish colored iLogic code?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes