Thank you Jaime,
I have found Reference Plane by filtering Sketch Planes in my Family Document and chose appropriate one by its name.
FilteredElementCollector collectorSP = new FilteredElementCollector(familyDocument).OfClass(typeof(SketchPlane));
SketchPlane skethPlane = null;
foreach (SketchPlane sp in collectorSP)
{
if (sp.Name == "Reference Lines")
{
skethPlane = sp;
break;
}
}
if (skethPlane == null) return;
Now I have another problem - I want to place new family instance on that plane. To explain, I am now creating family witch has inside another family, so I want to insert that “second’ family in working one, let’s call working family MainFamily and second SecondFamily. For that, I have used method NewFamilyInstance with next parameters:
NewFamilyInstance(Reference reference, XYZ location, XYZ referenceDirection, FamilySymbol symbol);
- reference: skethPlane.GetPlaneReference() – reference from filtered skethPlane.
- location:GeometryCurve.GetEndPoint(0) – start point of reference line in MainFamily (working family)
- referenceDirection: GeometryCurve.GetEndPoint(1) - referenceLine.GeometryCurve.GetEndPoint(0) – direction of line
- symbol: symbol of SecondFamily
In SecondFamily I set parameter FAMILY_WORK_PLANE_BASED to true. familyDocument.OwnerFamily.get_Parameter(BuiltInParameter.FAMILY_WORK_PLANE_BASED).Set(1);
All that together looks like this:
FamilyInstance instance = familyDocument.FamilyCreate.NewFamilyInstance(skethPlane.GetPlaneReference(), referenceLine.GeometryCurve.GetEndPoint(0),
referenceLine.GeometryCurve.GetEndPoint(1) - referenceLine.GeometryCurve.GetEndPoint(0), profileSymbol);
But, it have not worked when I moved reference line I got warning or there is not connection between instance and reference plane from reference line. Do you have an idea what to do? Again, I want to place my SecondFamily on WorkPlane picked on ReferenceLine from MainFamily…