Orient Object and move

Hi Guys,

The code for orient object on surface : http://wiki.mcneel.com/developer/sdksamples/orientonsrf

How can i move the object on Z direction after picking the surface to orient on ??

for example : if the center part is located at (0,0,0) i want to move the object 0.5 MM on Z axis but perpendicular to the surface at orientation point after selecting the surface to orient

Maybe you could move your source plane down before orienting the object ?

I don’t know the C++ syntax, but it may be around there :

ON_Plane source_plane( view->Viewport().ConstructionPlane().m_plane );
source_plane.SetOrigin( gp.Point() );

I think it’s much simpler, if I understand you correctly.

Calculate the angle between the z-axis and the orientation vector. The the distance you should move along the orientation vector to move 0.5 mm in the z-direction is given by: 0.5/cos(angle).

This can easily be achieved using a translation transform.

Can you pls paste a piece of code in VB.net ?
I mean how to calculate the angle ??

Or is it possible to align the axises of the object along with the object to the target place so all the translation and scaling can be done on the object axises ??

There is one thing i would like to tell you that. when i tried to rotate the object by using
target_plane.Rotate(XAngle, target_plane.xaxis, target_plane.origin)
object rotates in aligned axis. So if i could move the object in the target_plane.zaxis then i will get what i want
but i did not find the way to do it.

Sorry, I’m unable to post code asset the moment…