As an aside to my other live discussion thread, I was testing my existing code using the sloping line element but I changed the test coordinate so that it was no longer planar on the XY plane with the line element and its perpendicular intersection. I was curious to see if the ProjectPointOnPerpendicular would return the same coordinate it was planar. Sadly it doesn't and cells are result is that cells are no longer inserted perpendicular to the target element so its critical that I find a solution to ensure that the correct point is returned. I need the method to operate as just a the command 'Trim to Element' can project a line to intersect with a non-planar element. Reviewing the VBA on ProjectPointOnPerpendicular I noticed my old foe Matrix3D is the 2nd parameter and to date using elements planar to my coordinates, I have this parameter set to MatrixIdentity. I attempted the following modification having read a similar solution in another thread:
Dim Axis As Long Dim RotMatrix As Matrix3d Axis = 2 dRadians = Radians(90) RotMatrix = Matrix3dFromAxisAndRotationAngle(Axis, dRadians) ... Case msdElementTypeLine, msdElementTypeLineString ProjectedPoint = oElement.AsLineElement.ProjectPointOnPerpendicular(SourceCoordinate, RotMatrix)
This wasn't successful and the inserted cell matches the same rotation as using MatrixIndentity.
How can I calculate the 'theoretical' perpendicular intersection from a coordinate on its XY plane to an element which may have vertices that lie at varying Z coordinates?