Message 1 of 11
Not applicable
11-15-2019
11:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I tried to get Reference Point from FamilyInstance by this code from TheBuildingCoder blog:
Reference reference = sectionInstance.get_Geometry(options).OfType<Point>().Select<Point, Reference>(x => x.Reference).FirstOrDefault();
Unfortunately I recive null. In family creator I can get ReferencePoint using Dynamo using ReferencePoint.ByPoint so Im sure that those points exist. I tried to recive those point in both by family creator and project. I have two family instances in which I want to use this Conceptual Mass and Adaptive.
Here is full code:
public static Reference GetReferencePoint(string targetSectionName)
{
Options options = new Options();
options.ComputeReferences = true;
options.DetailLevel = ViewDetailLevel.Undefined;
options.IncludeNonVisibleObjects = true;
//Set document as current document
Document document = RevitServices.Persistence.DocumentManager.Instance.CurrentDBDocument;
//Collect FamilyInstances
var symbolCollector = new FilteredElementCollector(document)
.OfClass(typeof(FamilyInstance));
//Get FamilyInstance by name
FamilyInstance sectionInstance = symbolCollector
.Where(x => ((FamilyInstance)x).Symbol.Name.Equals(targetSectionName))
.Cast<FamilyInstance>()
.FirstOrDefault();
using (Transaction transaction = new Transaction(document, "GetReferencePoint"))
{
transaction.Start();
Reference reference = sectionInstance.get_Geometry(options).OfType<Point>().Select<Point, Reference>(x => x.Reference).FirstOrDefault();
transaction.Commit();
return reference;
}
}
Solved! Go to Solution.