/***************************************************/ private static Element ToRevitElement(this ModelInstance modelInstance, FamilySymbol familySymbol, RevitSettings settings) { Document doc = familySymbol.Document; if (AdaptiveComponentInstanceUtils.IsAdaptiveFamilySymbol(familySymbol)) { List <IGeometry> pts = (modelInstance.Location as CompositeGeometry)?.Elements; if (pts == null || !pts.All(x => x is BH.oM.Geometry.Point)) { BH.Engine.Reflection.Compute.RecordError($"A family could not be created based on the given ModelInstance because its family type is adaptive, but location was not a collection of points. BHoM_Guid: {modelInstance.BHoM_Guid}"); return(null); } return(Create.AdaptiveComponent(doc, familySymbol, pts.Select(x => ((BH.oM.Geometry.Point)x).ToRevit()).ToList(), settings)); } if (modelInstance.Location is BH.oM.Geometry.Point) { return(Create.FamilyInstance(doc, familySymbol, ((BH.oM.Geometry.Point)modelInstance.Location).ToRevit(), modelInstance.Orientation.ToRevit(), doc.GetElement(new ElementId(modelInstance.HostId)), settings)); } else if (modelInstance.Location is ICurve) { return(Create.FamilyInstance(doc, familySymbol, ((ICurve)modelInstance.Location).IToRevit(), doc.GetElement(new ElementId(modelInstance.HostId)), settings)); } else { BH.Engine.Reflection.Compute.RecordError($"A family could not be created based on the given ModelInstance because its location was neither a point nor a curve. BHoM_Guid: {modelInstance.BHoM_Guid}"); return(null); } }
/***************************************************/ private static Element ToRevitElement(this ModelInstance modelInstance, FamilySymbol familySymbol, RevitSettings settings) { Document doc = familySymbol.Document; if (modelInstance.Location is BH.oM.Geometry.Point) { return(Create.FamilyInstance(doc, familySymbol, ((BH.oM.Geometry.Point)modelInstance.Location).ToRevit(), modelInstance.Orientation.ToRevit(), doc.GetElement(new ElementId(modelInstance.HostId)), settings)); } if (modelInstance.Location is ICurve) { return(Create.FamilyInstance(doc, familySymbol, ((ICurve)modelInstance.Location).IToRevit(), doc.GetElement(new ElementId(modelInstance.HostId)), settings)); } else { BH.Engine.Reflection.Compute.RecordError($"A family could not be created based on the given ModelInstance because its location was neither a point nor a curve. BHoM_Guid: {modelInstance.BHoM_Guid}"); return(null); } }
/***************************************************/ private static Element ToRevitElement(this DraftingInstance draftingInstance, FamilySymbol familySymbol, View view, RevitSettings settings) { if (draftingInstance?.Location == null) { return(null); } if (draftingInstance.Location is ICurve) { return(Create.FamilyInstance(familySymbol.Document, familySymbol, ((ICurve)draftingInstance.Location).IToRevit(), view, settings)); } else if (draftingInstance.Location is BH.oM.Geometry.Point) { return(Create.FamilyInstance(familySymbol.Document, familySymbol, ((BH.oM.Geometry.Point)draftingInstance.Location).ToRevit(), draftingInstance.Orientation.ToRevit(), view, settings)); } else { return(null); } }