1)Simple small minimum Non-confidential sample code
Element beam = doc.GetElement(beamId);
Line beamCurve = (beam.Location as LocationCurve).Curve as Line;
XYZ start = beamCurve.GetEndPoint(0);
XYZ end = beamCurve.GetEndPoint(1);
XYZ mid = (start + end) / 2;
// Get top face of beam element
Face beamTopFace = BeamGeometry.GetBeamVectorFace(beam, Autodesk.Revit.DB.XYZ.BasisZ);
XYZ direction = (beamTopFace as PlanarFace).FaceNormal.CrossProduct(XYZ.BasisZ);
if (direction.IsZeroLength())
{
direction = (beamTopFace as PlanarFace).FaceNormal.CrossProduct(XYZ.BasisX);
}
if (!familySymbol.IsActive)
{
familySymbol.Activate();
doc.Regenerate();
}
doc.Create.NewFamilyInstance(beamTopFace, mid, direction, familySymbol);
2)Simple small minimum Non-confidential Sample file and family file
Sample project: Project1 (note that the middle beam that has a corner cut doesn't fail he sample code)
sample family: EST-InsertoEstrutural-7TS
3)Step by Step approach to reproduce the issue(UI and API)
Via UI the problem doesn't occur. To reproduce via API:
1) select one concrete pre-cast beam (set beamId to the element.Id) that has not been modified in the model, only placed
2) set familySymbol with the structural-connection family
3) run the sample code
4) get the error
To avoid error:
1) through UI modify the target (beamId) pre-cast beam (open it's face, place a structural connection, whatever)
2) set familySymbol with the structural-connection family
3) select one concrete pre-cast beam that has not been modified in the model, only placed
4) run the sample code
5) structural connection placed successfully
4)Observed Result vs Expected Result
Observed: Error "A serious error has occurred. " when beam was not modified between placing it in the model and running sample code. (To reproduce select "virgin" beam and run sample code).
Expected result: Structural connection family placed in the middle of selected beam without any error. (To reproduce open a corner of the beam's face before running sample code).
5)Revit Version details.
Revit FULL 2021.1.2.
*same occurs to Revit FULL 2022