/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static ModelInstance ModelInstanceFromRevit(this FamilyInstance adaptiveComponent, RevitSettings settings = null, Dictionary <string, List <IBHoMObject> > refObjects = null) { settings = settings.DefaultIfNull(); ModelInstance modelInstance = refObjects.GetValue <ModelInstance>(adaptiveComponent.Id); if (modelInstance != null) { return(modelInstance); } ElementType elementType = adaptiveComponent.Document.GetElement(adaptiveComponent.GetTypeId()) as ElementType; InstanceProperties instanceProperties = elementType.InstancePropertiesFromRevit(settings, refObjects) as InstanceProperties; IEnumerable <BH.oM.Geometry.Point> pts = AdaptiveComponentInstanceUtils.GetInstancePointElementRefIds(adaptiveComponent).Select(x => ((ReferencePoint)adaptiveComponent.Document.GetElement(x)).Position.PointFromRevit()); modelInstance = new ModelInstance { Properties = instanceProperties, Location = new CompositeGeometry { Elements = new List <IGeometry>(pts) } }; modelInstance.Name = adaptiveComponent.Name; //Set identifiers, parameters & custom data modelInstance.SetIdentifiers(adaptiveComponent); modelInstance.CopyParameters(adaptiveComponent, settings.ParameterSettings); modelInstance.SetProperties(adaptiveComponent, settings.ParameterSettings); refObjects.AddOrReplace(adaptiveComponent.Id, modelInstance); return(modelInstance); }