/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static Autodesk.Revit.DB.Mechanical.DuctType ToRevitElementType(this oM.MEP.System.SectionProperties.DuctSectionProperty property, Document document, IEnumerable <BuiltInCategory> categories = null, RevitSettings settings = null, Dictionary <Guid, List <int> > refObjects = null) { if (property == null || document == null) { return(null); } Autodesk.Revit.DB.Mechanical.DuctType elementType = refObjects.GetValue <Autodesk.Revit.DB.Mechanical.DuctType>(document, property.BHoM_Guid); if (elementType != null) { return(elementType); } settings = settings.DefaultIfNull(); elementType = property.ElementType(document, categories, settings) as Autodesk.Revit.DB.Mechanical.DuctType; if (elementType != null) { return(elementType); } List <Autodesk.Revit.DB.Mechanical.DuctType> ductTypes = new FilteredElementCollector(document).OfClass(typeof(Autodesk.Revit.DB.Mechanical.DuctType)).Cast <Autodesk.Revit.DB.Mechanical.DuctType>().ToList(); if (property.SectionProfile.ElementProfile is BH.oM.Spatial.ShapeProfiles.BoxProfile) { elementType = ductTypes.FirstOrDefault(x => x.FamilyName == "Rectangular Duct"); } else if (property.SectionProfile.ElementProfile is BH.oM.Spatial.ShapeProfiles.TubeProfile) { elementType = ductTypes.FirstOrDefault(x => x.FamilyName == "Round Duct"); } // Add more shapeProfiles when available if (elementType != null) { BH.Engine.Reflection.Compute.RecordNote($"Duct is being pushed as the first type available in the Revit model, in this case {elementType.Name}."); } else { return(null); } // Copy parameters from BHoM object to Revit element elementType.CopyParameters(property, settings); refObjects.AddOrReplace(property, elementType); return(elementType); }
/// <summary> /// Initialize a Duct element /// </summary> /// <param name="pipeType">Type of the pipe.</param> /// <param name="systemType">Type of the system.</param> /// <param name="start">The start.</param> /// <param name="end">The end.</param> /// <param name="level">The level.</param> private void InitPipe(Autodesk.Revit.DB.Mechanical.DuctType pipeType, Autodesk.Revit.DB.Mechanical.MechanicalSystemType systemType, XYZ start, XYZ end, Autodesk.Revit.DB.Level level) { //Phase 1 - Check to see if the object exists and should be rebound var oldFam = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.MEPCurve>(DocumentManager.Instance.CurrentDBDocument); //There was a point, rebind to that, and adjust its position if (oldFam != null) { InternalSetMEPCurve(oldFam); InternalSetMEPCurveType(pipeType); InternalSetPosition(start, end); return; } //Phase 2- There was no existing point, create one TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument); Autodesk.Revit.DB.MEPCurve fi; if (DocumentManager.Instance.CurrentDBDocument.IsFamilyDocument) { fi = null; } else { fi = Autodesk.Revit.DB.Mechanical.Duct.Create(DocumentManager.Instance.CurrentDBDocument, systemType.Id, pipeType.Id, level.Id, start, end); } InternalSetMEPCurve(fi); TransactionManager.Instance.TransactionTaskDone(); ElementBinder.SetElementForTrace(InternalElement); }
/// <summary> /// Initializes a new instance of the <see cref="Duct"/> class. /// </summary> /// <param name="pipeType">Type of the pipe.</param> /// <param name="systemType">Type of the system.</param> /// <param name="start">The start.</param> /// <param name="end">The end.</param> /// <param name="level">The level.</param> internal Duct(Autodesk.Revit.DB.Mechanical.DuctType pipeType, Autodesk.Revit.DB.Mechanical.MechanicalSystemType systemType, XYZ start, XYZ end, Autodesk.Revit.DB.Level level) { InitPipe(pipeType, systemType, start, end, level); }