Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am using Revit 2016 API to create a family with nest family instance. I want to align inserted family instance with a reference line but getting the error message below.
Autodesk.Revit.Exceptions.ArgumentException was unhandled by user code
HResult=-2146233088
Message=One of the conditions for the inputs was not satisfied. Consult the documentation for requirements for each argument.
Below is the code to call NewAlignment.
{ ... ModelCurve line3 = MakeLine(document, new XYZ(10, 10, 0), new XYZ(5, 15, 0)); line3.ChangeToReferenceLine(); Reference refPlaneLeft = GetFamilyInstanceLeftReferencePlane(viewPlan, familyInstance); if (refPlaneLeft != null) { Dimension alignToLine3 = document.FamilyCreate.NewAlignment(viewPlan, line3.GeometryCurve.Reference, refPlaneLeft); alignToLine3.IsLocked = true; } ... } private Reference GetFamilyInstanceLeftReferencePlane( View view, FamilyInstance fi) { Reference referenceLeft = null; Options opt = new Options(); opt.ComputeReferences = true; opt.IncludeNonVisibleObjects = true; if (view != null) opt.View = view; double minX = double.MaxValue; GeometryElement ge = fi.get_Geometry(_opt); if (ge != null) { foreach (GeometryObject go in ge) { if (go is GeometryInstance) { GeometryInstance gi = go as GeometryInstance; foreach (GeometryObject goSymbol in gi.GetSymbolGeometry()) { if (goSymbol is Line) { Line refPlane = goSymbol as Line; if (refPlane.Direction.IsAlmostEqualTo(new XYZ(0, 1, 0)) || refPlane.Direction.IsAlmostEqualTo(new XYZ(0, -1, 0))) { if (refPlane.GetEndPoint(0).X < minX) { minX = refPlane.GetEndPoint(0).X; referenceLeft = refPlane.Reference; } } } } } } } return referenceLeft; }
Does GetFamilyInstanceLeftReferencePlane() not get the correct Reference of FamilyInstance's ReferencePlane? Or, is there a better way to align FamilyInstance to a reference line?
Thanks
Solved! Go to Solution.