I need to align the red shaped block on the blue line, so that then I can use sweep2 and basically flow the block along 2 rails.
However I am having troubles using Rotation Matrix to align the block to the blue curve, how would you go about that?

traccia2 = traccia1.OffsetNormalToSurface(srf, hprof*-1); //this is the blue curve
var idef = doc.InstanceDefinitions.Find(name, true);
Guid profilo2dguid = doc.Objects.AddInstanceObject(idef.Index, xform);

Hi,
I’ve already done everything, it does insert the block in the correct position as shown in the screenshot, and does normal offset to srf in order to obtain the red curve.
Now I want to orient the blue object, so that it’s direction is the same as the red curve, basically rotate it in this case, however what I want to do is : to orient the blue shape (block) as shown by the grey curve and red curve. Thank you in advance for your help

Actual working solution im satisfied with if anyone has the same issue

public void RotateObject(Surface superficie, Surface srf, Point3d point,Curve joined)
{
Surface curve = superficie;
// Get the normal at the specified point
Point3d closestPoint;
double u, v;
if (!srf.ClosestPoint(point, out u, out v)) return;
Vector3d normal = srf.NormalAt(u, v);
Vector3d normalcrv = curve.NormalAt(u, v);
// Calculate the angle of rotation to align with the normal
double angle = Vector3d.VectorAngle(normalcrv, normal);
// Convert the angle from degrees to radians
angle = angle * (Math.PI / 180);
// Rotate the curve to align with the normal
curve.Rotate(angle,normalcrv, point);
}