Align beams to reference lines

Good morning.

Can any Revit API method let me align beams to reference lines in order?
Because I want to relocate beams to new position with all previous information.

So far, I have studied a function , PostCommmand, Which can allow me to use the ‘Align’ Command in Revit, But, it is not totally automatically since I need to select elements in Revit view.

P.S. Reference I studied about PostCommand

Therefore, I am wondering that whether having a function or workflow can allow me input target reference lines and beam elements, then do a for loop, so I can automatically align and relocate beams to where what I want in order.

Any help is greatly appreciated. Thank you in advance.

You can use the OOTB Element.SetLocation node or one of the 3rd party equivalents.

Ah, I see you want an API method. You can get the Location of the element with element.Location which will give you a LocationCurve object and then you can set the LocationCurve.Curve with a curve of your choice.

@hctungBHP7B something like this will work:

If you want to align the middle of the beam to the lines using the Revit API, it is as easy as @Daniel_Woodcock1 mentioned, but if you want to align to the outer or inner face of the beams, I guess it is easier to go by Dynamo nodes.