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.
Hi,
I think Point3dProjectToPlane3d method is what are you looking for.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Thanks Jan for your quick response.
How can I create a plane3d using the available (Rectangle)shape Element? can you please send me a sample code?
Unknown said:How can I create a plane3d using the available shape Element?
The Plane3d user-defined-type (UDT) is described in VBA help .
Represents a plane in three-dimensional space.
The Plane3d type has these members:
I suggest that you obtain the shape element normal and use one of its vertices as the origin.
Regards, Jon Summers LA Solutions
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 planeYellow 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.ZEnd SubPrivate 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 = prPtEnd Function
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,
Thank Jan. It's working fine by using ViewSpecifier parameter(without loop).
Dharma