You can adjust analytical lines to adjust the analytical model using API. Basically, AnalyticalModel.ManuallyAdjust method can mimic Analyze tab>Analytical Model Tools panel>Analytical Adjust feature in UI.
For adjusting the anlytical model, pleae take a look at “Adjusting Columns to Beams” in Revit WikiHelp.
Here is the sample code for an usage of AnalyticalModel.ManuallyAdjust method.
[TransactionAttribute(TransactionMode.Manual)]
public class RevitCommand : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string messages,
ElementSet elements)
{
UIApplication app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;
Transaction trans = new Transaction(doc, "TEST");
trans.Start();
//pick the source analytical model.
//
Selection sel = app.ActiveUIDocument.Selection;
Reference refAnalytical = sel.PickObject(
ObjectType.Element,
"Please pick the source analytical line");
AnalyticalModel aModel =
doc.GetElement(refAnalytical) as AnalyticalModel;
Curve aCurve = aModel.GetCurve();
AnalyticalModelSelector aSelector =
new AnalyticalModelSelector(aCurve);
aSelector.CurveSelector = AnalyticalCurveSelector.EndPoint;
Reference refSource = aModel.GetReference(aSelector);
//pick the target analytical model
//
Reference refAnalytical2 = sel.PickObject(
ObjectType.Element,
"Please pick the target analytical line");
AnalyticalModel aModel2 =
doc.GetElement(refAnalytical2) as AnalyticalModel;
Curve aCurve2 = aModel2.GetCurve();
AnalyticalModelSelector aSelector2 =
new AnalyticalModelSelector(aCurve2);
aSelector2.CurveSelector =
AnalyticalCurveSelector.StartPoint;
Reference refTarget = aModel2.GetReference(aSelector2);
aModel.ManuallyAdjust(refSource, refTarget, true);
trans.Commit();
return Result.Succeeded;
}
}
As shown at the step 3 of “Adjusting Columns to Beams” in Revit WikiHelp, this code automatically adjust the analytical line. In this case, you need to know which is start and end point, and set AnalyticalCurveSelector.
If you use AnalyticalCurveSelector.WholeCurve for the anlytical line of the beam, the analytical line of the column is projected to the analytical line of the beam (not the end point) for the adjustment.
An end point of the analytical line can be moved by AnalyticalModel.SetOffset.