Project Point onto a Plane

Dear All,

I have a point3d values and a Plane/Surface. I want to project the point onto a Plane/Surface. How Can I get that projected point using VBA Programming? Kindly clarify.

Please refer the attachment:

In the attachment Cyan color represents the projected point from a vertices on the shape element(blue colored) to the plane/Surface(majenta colored).

Majenta Colored and Blue colored Elements are input. Cyan Colored Element is the output which I want.

Parents Reply
  • Unknown said:
    How can I create a plane3d using the available shape Element?

    The Plane3d user-defined-type (UDT) is described in
    VBA Help
    VBA help .

    Plane3d Type

    Represents a plane in three-dimensional space.

    The Plane3d type has these members:

    NameDescription
    Origin A Point3d value that represents the origin point of the plane.
    Normal A Point3d value that represents the normal vector of the plane.

    I suggest that you obtain the shape element normal and use one of its vertices as the origin.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Children
  • Thanks Jon.
    
    
    I checked it. It produces a point perpendicular to the plane (or) the Nearest Point on Plane. 
    But I want to get the height(Z values) on a plane corresponding to XY values. Is there anyother option?

    Refer the attachment:
    Majenta color represents the plane
    Yellow color represents output of 'Point3dProjectToPlane3d' method
    Cyan color represents the output required (XY values remains unchanged).
    
    
    I will manage with 'Point3dProjectToPlane3d' as given in the below sample Code. 
    But it will be a time consuming one. I am looking for other options without using loops.
    Code:-
    Private Sub projectPointOnShape()
    Dim selEnum As ElementEnumerator
    Dim selEle1 As ShapeElement
    Dim planeEle2 As ShapeElement
    Dim tmpVert1() As Point3d
    Dim tmpVert2() As Point3d
    Dim prjPt As Point3d
    Dim plane As Plane3d

    Set selEnum = ActiveModelReference.GetSelectedElements
    selEnum.MoveNext
    Set selEle1 = selEnum.Current
    tmpVert1 = selEle1.GetVertices
    selEnum.MoveNext
    Set planeEle2 = selEnum.Current
    tmpVert2 = planeEle2.GetVertices

    plane.Origin = tmpVert2(0)
    plane.normal = planeEle2.normal

    prjPt = getProjectedPoints(plane, tmpVert1(2))

    Debug.Print prjPt.X & prjPt.Y & prjPt.Z
    End Sub

    Private Function getProjectedPoints(pl As Plane3d, pt As Point3d) As Point3d
    Dim tmpPt As Point3d
    Dim prPt As Point3d
    tmpPt = Point3dProjectToPlane3d(pt, pl)
    While tmpPt.X <> pt.X Or tmpPt.Y <> pt.Y
    prPt = tmpPt
    prPt.X = pt.X
    prPt.Y = pt.Y
    tmpPt = Point3dProjectToPlane3d(prPt, pl)
    Wend
    prPt = tmpPt
    prPt.X = pt.X
    prPt.Y = pt.Y

    getProjectedPoints = prPt
    End Function
    
    
    
    

  • Hi,

    Unknown said:
    I checked it. It produces a point perpendicular to the plane (or) the Nearest Point on Plane.But I want to get the height(Z values) on a plane corresponding to XY values. Is there anyother option?

    In my opinion, if you will use an optional ViewSpecifier parameter and will rotate this view to top, you will receive the result you need.

    Regards,

      Jan

  • Thank Jan. It's working fine by using ViewSpecifier parameter(without loop).

    Regards,

    Dharma