diff --git a/.gitignore b/.gitignore index 93d7e05bb..e1d71ce3c 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ local.properties *.suo *.user *.sln.docstates +/src/Config/user_local.props # Build results diff --git a/.version b/.version index 8f1a86948..e9acb99e6 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.6.11 \ No newline at end of file +0.6.12 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 00adad167..7abe1f22c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.12 +* Fix CurtainPanel.ByElements failing to return when there is a door or window present in the curtain wall +* Stop tracking user_local.props in git so local setup for building DynamoRevit doesn't get pushed by mistake on remote server + ## 0.6.11 * Update Dynamo Core to 3.0.4.7905 diff --git a/src/Config/user_local.props b/src/Config/user_local.props deleted file mode 100644 index 7cf7f0e5c..000000000 --- a/src/Config/user_local.props +++ /dev/null @@ -1,13 +0,0 @@ - - - - Preview Release - Revit - - $(SolutionDir)..\bin\$(Platform)\$(Configuration)\$(REVIT_VERSION) - $(OutputPath) - - - E:\RevitVersion\2025\Releasex64_NET7_20230907\Releasex64 - - \ No newline at end of file diff --git a/src/Libraries/RevitNodes/Elements/CurtainPanel.cs b/src/Libraries/RevitNodes/Elements/CurtainPanel.cs index 72a621ecf..a1cddce53 100644 --- a/src/Libraries/RevitNodes/Elements/CurtainPanel.cs +++ b/src/Libraries/RevitNodes/Elements/CurtainPanel.cs @@ -18,463 +18,471 @@ namespace Revit.Elements /// A Revit CurtainPanel /// public class CurtainPanel : AbstractFamilyInstance - { - #region Properties + { + #region Properties - protected CurveArrArray PanelBoundaries - { - get - { - // This creates a new wall and deletes the old one - TransactionManager.Instance.EnsureInTransaction(Document); - - var elementAsPanel = InternalElement as Autodesk.Revit.DB.Panel; - if (elementAsPanel == null) - throw new Exception(Properties.Resources.CurtainPanelInternalElementError); - - var host = elementAsPanel.Host; - - CurtainGrid hostingGrid = null; - Autodesk.Revit.DB.CurtainGrid grid = null; - if (host is Autodesk.Revit.DB.Wall) + protected CurveArrArray PanelBoundaries + { + get { - hostingGrid = CurtainGrid.ByElement(UnknownElement.FromExisting(host, true)); + // This creates a new wall and deletes the old one + TransactionManager.Instance.EnsureInTransaction(Document); + + var elementAsPanel = InternalElement as Autodesk.Revit.DB.Panel; + if (elementAsPanel == null) + throw new Exception(Properties.Resources.CurtainPanelInternalElementError); + + var host = elementAsPanel.Host; + + CurtainGrid hostingGrid = null; + Autodesk.Revit.DB.CurtainGrid grid = null; + if (host is Autodesk.Revit.DB.Wall) + { + hostingGrid = CurtainGrid.ByElement(UnknownElement.FromExisting(host, true)); + } + else + { + var gridSet = CurtainGrid.AllCurtainGrids(host); + var enumGrid = gridSet.GetEnumerator(); + bool found = false; + for (; enumGrid.MoveNext();) + { + grid = (Autodesk.Revit.DB.CurtainGrid)enumGrid.Current; + if (grid.GetPanelIds().Contains(elementAsPanel.Id)) + { + found = true; + break; + } + } + if (!found) + throw new Exception(Properties.Resources.CellForPanelNotFound); + } + + ElementId uGridId = ElementId.InvalidElementId; + ElementId vGridId = ElementId.InvalidElementId; + elementAsPanel.GetRefGridLines(ref uGridId, ref vGridId); + + if (grid == null && hostingGrid == null) + throw new Exception(Properties.Resources.CellForPanelNotFound); + + CurtainCell cell = hostingGrid != null + ? hostingGrid.InternalCurtainGrid.GetCell(uGridId, vGridId) + : grid.GetCell(uGridId, vGridId); + + TransactionManager.Instance.TransactionTaskDone(); + + if (cell == null) + throw new Exception(Properties.Resources.CellForPanelNotFound); + return cell.CurveLoops; } - else + } + + private PolyCurve[] boundsCache = null; + /// + /// Gets curtain panel boundaries + /// + public PolyCurve[] Boundaries + { + get { - var gridSet = CurtainGrid.AllCurtainGrids(host); - var enumGrid = gridSet.GetEnumerator(); - bool found = false; - for (; enumGrid.MoveNext();) - { - grid = (Autodesk.Revit.DB.CurtainGrid)enumGrid.Current; - if (grid.GetPanelIds().Contains(elementAsPanel.Id)) - { - found = true; - break; - } - } - if (!found) - throw new Exception(Properties.Resources.CellForPanelNotFound); + if (boundsCache != null) + return boundsCache; + var enumCurveLoops = PanelBoundaries.GetEnumerator(); + var bounds = new List(); + + for (; enumCurveLoops.MoveNext();) + { + var crvs = new CurveArray(); + var crvArr = (CurveArray)enumCurveLoops.Current; + var enumCurves = crvArr.GetEnumerator(); + for (; enumCurves.MoveNext();) + { + var crv = (Autodesk.Revit.DB.Curve)enumCurves.Current; + crvs.Append(crv); + } + //try + //{ + bounds.Add(Revit.GeometryConversion.RevitToProtoCurve.ToProtoType(crvs)); + //} + /* debugging code + catch (Exception e) + { + var cl = new CurveLoop(); + var enumCurvesCl = crvArr.GetEnumerator(); + for (; enumCurvesCl.MoveNext(); ) + { + var crv = (Autodesk.Revit.DB.Curve)enumCurvesCl.Current; + cl.Append(crv); + } + double len = cl.GetExactLength(); + len = len/1.0; + } + end of debugging code */ + } + boundsCache = bounds.ToArray(); + return boundsCache; } - - ElementId uGridId = ElementId.InvalidElementId; - ElementId vGridId = ElementId.InvalidElementId; - elementAsPanel.GetRefGridLines(ref uGridId, ref vGridId); - - if (grid == null && hostingGrid == null) - throw new Exception(Properties.Resources.CellForPanelNotFound); - - CurtainCell cell = hostingGrid != null - ? hostingGrid.InternalCurtainGrid.GetCell(uGridId, vGridId) - : grid.GetCell(uGridId, vGridId); - - TransactionManager.Instance.TransactionTaskDone(); - - if (cell == null) - throw new Exception(Properties.Resources.CellForPanelNotFound); - return cell.CurveLoops; - } - } - - private PolyCurve[] boundsCache = null; - /// - /// Gets curtain panel boundaries - /// - public PolyCurve[] Boundaries - { - get - { - if (boundsCache != null) - return boundsCache; - var enumCurveLoops = PanelBoundaries.GetEnumerator(); - var bounds = new List(); - - for (; enumCurveLoops.MoveNext();) + } + /// + /// Checks if the specific curtain panel is planar + /// + public bool HasPlane + { + get { - var crvs = new CurveArray(); - var crvArr = (CurveArray) enumCurveLoops.Current; - var enumCurves = crvArr.GetEnumerator(); - for (; enumCurves.MoveNext();) - { - var crv = (Autodesk.Revit.DB.Curve) enumCurves.Current; - crvs.Append(crv); - } - //try - //{ - bounds.Add(Revit.GeometryConversion.RevitToProtoCurve.ToProtoType(crvs)); - //} - /* debugging code - catch (Exception e) - { - var cl = new CurveLoop(); - var enumCurvesCl = crvArr.GetEnumerator(); - for (; enumCurvesCl.MoveNext(); ) - { - var crv = (Autodesk.Revit.DB.Curve)enumCurvesCl.Current; - cl.Append(crv); - } - double len = cl.GetExactLength(); - len = len/1.0; - } - end of debugging code */ + var enumCurveLoops = PanelBoundaries.GetEnumerator(); + Autodesk.Revit.DB.Plane plane = null; + for (; enumCurveLoops.MoveNext();) + { + var cLoop = new CurveLoop(); + var crvArr = (CurveArray)enumCurveLoops.Current; + var enumCurves = crvArr.GetEnumerator(); + for (; enumCurves.MoveNext();) + { + var crv = (Autodesk.Revit.DB.Curve)enumCurves.Current; + cLoop.Append(crv); + } + if (!cLoop.HasPlane()) + return false; + var thisPlane = cLoop.GetPlane(); + if (plane == null) + plane = thisPlane; + else if (Math.Abs(plane.Normal.DotProduct(thisPlane.Normal)) < 1.0 - 1.0e-9) + return false; + else + { + if (Math.Abs((plane.Origin - thisPlane.Origin).DotProduct(plane.Normal)) > 1.0e-9) + return false; + } + } + return true; } - boundsCache = bounds.ToArray(); - return boundsCache; - } - } - /// - /// Checks if the specific curtain panel is planar - /// - public bool HasPlane - { - get - { - var enumCurveLoops = PanelBoundaries.GetEnumerator(); - Autodesk.Revit.DB.Plane plane = null; - for (; enumCurveLoops.MoveNext();) + } + /// + /// Gets a plane of the given curtain panel, if it is planar + /// + public Plane PanelPlane + { + get { - var cLoop = new CurveLoop(); - var crvArr = (CurveArray) enumCurveLoops.Current; - var enumCurves = crvArr.GetEnumerator(); - for (; enumCurves.MoveNext();) - { - var crv = (Autodesk.Revit.DB.Curve) enumCurves.Current; - cLoop.Append(crv); - } - if (!cLoop.HasPlane()) - return false; - var thisPlane = cLoop.GetPlane(); - if (plane == null) - plane = thisPlane; - else if (Math.Abs(plane.Normal.DotProduct(thisPlane.Normal)) < 1.0 - 1.0e-9) - return false; - else - { - if (Math.Abs((plane.Origin - thisPlane.Origin).DotProduct(plane.Normal)) > 1.0e-9) - return false; - } + var enumCurveLoops = PanelBoundaries.GetEnumerator(); + Autodesk.Revit.DB.Plane plane = null; + for (; enumCurveLoops.MoveNext();) + { + var cLoop = new CurveLoop(); + var crvArr = (CurveArray)enumCurveLoops.Current; + var enumCurves = crvArr.GetEnumerator(); + for (; enumCurves.MoveNext();) + { + var crv = (Autodesk.Revit.DB.Curve)enumCurves.Current; + cLoop.Append(crv); + } + if (!cLoop.HasPlane()) + throw new Exception(Properties.Resources.CurtainPanelIsNotPlanar); + var thisPlane = cLoop.GetPlane(); + if (plane == null) + plane = thisPlane; + else if (Math.Abs(plane.Normal.DotProduct(thisPlane.Normal)) < 1.0 - 1.0e-9) + throw new Exception(Properties.Resources.CurtainPanelIsNotPlanar); + else + { + if (Math.Abs((plane.Origin - thisPlane.Origin).DotProduct(plane.Normal)) > 1.0e-9) + throw new Exception(Properties.Resources.CurtainPanelIsNotPlanar); + } + } + if (plane == null) + throw new Exception(Properties.Resources.CurtainPanelIsNotPlanar); + + return plane.ToPlane(); } - return true; - } - } - /// - /// Gets a plane of the given curtain panel, if it is planar - /// - public Plane PanelPlane - { - get - { - var enumCurveLoops = PanelBoundaries.GetEnumerator(); - Autodesk.Revit.DB.Plane plane = null; - for (; enumCurveLoops.MoveNext();) + } + /// + /// Gets the length of the specific curtain panel boundaries + /// + public double Length + { + get { - var cLoop = new CurveLoop(); - var crvArr = (CurveArray) enumCurveLoops.Current; - var enumCurves = crvArr.GetEnumerator(); - for (; enumCurves.MoveNext();) - { - var crv = (Autodesk.Revit.DB.Curve) enumCurves.Current; - cLoop.Append(crv); - } - if (!cLoop.HasPlane()) - throw new Exception(Properties.Resources.CurtainPanelIsNotPlanar); - var thisPlane = cLoop.GetPlane(); - if (plane == null) - plane = thisPlane; - else if (Math.Abs(plane.Normal.DotProduct(thisPlane.Normal)) < 1.0 - 1.0e-9) - throw new Exception(Properties.Resources.CurtainPanelIsNotPlanar); - else - { - if (Math.Abs((plane.Origin - thisPlane.Origin).DotProduct(plane.Normal)) > 1.0e-9) - throw new Exception(Properties.Resources.CurtainPanelIsNotPlanar); - } + double lengthVal = 0.0; + var enumCurveLoops = PanelBoundaries.GetEnumerator(); + for (; enumCurveLoops.MoveNext();) + { + var crvArr = (CurveArray)enumCurveLoops.Current; + var enumCurves = crvArr.GetEnumerator(); + for (; enumCurves.MoveNext();) + { + var crv = (Autodesk.Revit.DB.Curve)enumCurves.Current; + lengthVal += crv.Length; + } + } + return lengthVal * UnitConverter.HostToDynamoFactor(SpecTypeId.Length); } - if (plane == null) - throw new Exception(Properties.Resources.CurtainPanelIsNotPlanar); - - return plane.ToPlane(); - } - } - /// - /// Gets the length of the specific curtain panel boundaries - /// - public double Length - { - get - { - double lengthVal = 0.0; - var enumCurveLoops = PanelBoundaries.GetEnumerator(); - for (; enumCurveLoops.MoveNext();) + } + + /// + /// Checks whether the specific curtain panel is rectangular. Returns + /// true if the curtain panel is rectangular. Otherwise returns false + /// + public bool IsRectangular + { + get { - var crvArr = (CurveArray) enumCurveLoops.Current; - var enumCurves = crvArr.GetEnumerator(); - for (; enumCurves.MoveNext();) - { - var crv = (Autodesk.Revit.DB.Curve) enumCurves.Current; - lengthVal += crv.Length; - } + var enumCurveLoops = PanelBoundaries.GetEnumerator(); + int num = 0; + bool result = false; + for (; enumCurveLoops.MoveNext();) + { + if (num > 0) + return false; + num++; + var cLoop = new CurveLoop(); + var crvArr = (CurveArray)enumCurveLoops.Current; + var enumCurves = crvArr.GetEnumerator(); + for (; enumCurves.MoveNext();) + { + var crv = (Autodesk.Revit.DB.Curve)enumCurves.Current; + cLoop.Append(crv); + } + if (!cLoop.HasPlane()) + return false; + result = cLoop.IsRectangular(cLoop.GetPlane()); + } + return result; } - return lengthVal * UnitConverter.HostToDynamoFactor(SpecTypeId.Length); - } - } - - /// - /// Checks whether the specific curtain panel is rectangular. Returns - /// true if the curtain panel is rectangular. Otherwise returns false - /// - public bool IsRectangular - { - get - { - var enumCurveLoops = PanelBoundaries.GetEnumerator(); - int num = 0; - bool result = false; - for (; enumCurveLoops.MoveNext();) + } + /// + /// Gets the width of the specific curtain panel, if it's rectangular + /// + public double Width + { + get { - if (num > 0) - return false; - num++; - var cLoop = new CurveLoop(); - var crvArr = (CurveArray) enumCurveLoops.Current; - var enumCurves = crvArr.GetEnumerator(); - for (; enumCurves.MoveNext();) - { - var crv = (Autodesk.Revit.DB.Curve) enumCurves.Current; - cLoop.Append(crv); - } - if (!cLoop.HasPlane()) - return false; - result = cLoop.IsRectangular(cLoop.GetPlane()); + var enumCurveLoops = PanelBoundaries.GetEnumerator(); + int num = 0; + double result = 0.0; + for (; enumCurveLoops.MoveNext();) + { + if (num > 0) + throw new Exception(Properties.Resources.CurtainPanelIsNotRectangular); + num++; + var cLoop = new CurveLoop(); + var crvArr = (CurveArray)enumCurveLoops.Current; + var enumCurves = crvArr.GetEnumerator(); + for (; enumCurves.MoveNext();) + { + var crv = (Autodesk.Revit.DB.Curve)enumCurves.Current; + cLoop.Append(crv); + } + if (!cLoop.HasPlane()) + throw new Exception(Properties.Resources.CurtainPanelIsNotRectangular); + if (!cLoop.IsRectangular(cLoop.GetPlane())) + throw new Exception(Properties.Resources.CurtainPanelIsNotRectangular); + result = cLoop.GetRectangularWidth(cLoop.GetPlane()); + } + return result * UnitConverter.HostToDynamoFactor(SpecTypeId.Length); } - return result; - } - } - /// - /// Gets the width of the specific curtain panel, if it's rectangular - /// - public double Width - { - get - { - var enumCurveLoops = PanelBoundaries.GetEnumerator(); - int num = 0; - double result = 0.0; - for (; enumCurveLoops.MoveNext();) + } + /// + /// Gets the height of the specific curtain panel, if it's rectangular + /// + public double Height + { + get { - if (num > 0) - throw new Exception(Properties.Resources.CurtainPanelIsNotRectangular); - num++; - var cLoop = new CurveLoop(); - var crvArr = (CurveArray) enumCurveLoops.Current; - var enumCurves = crvArr.GetEnumerator(); - for (; enumCurves.MoveNext();) - { - var crv = (Autodesk.Revit.DB.Curve) enumCurves.Current; - cLoop.Append(crv); - } - if (!cLoop.HasPlane()) - throw new Exception(Properties.Resources.CurtainPanelIsNotRectangular); - if (!cLoop.IsRectangular(cLoop.GetPlane())) - throw new Exception(Properties.Resources.CurtainPanelIsNotRectangular); - result = cLoop.GetRectangularWidth(cLoop.GetPlane()); + var enumCurveLoops = PanelBoundaries.GetEnumerator(); + int num = 0; + double result = 0.0; + for (; enumCurveLoops.MoveNext();) + { + if (num > 0) + throw new Exception(Properties.Resources.CurtainPanelIsNotRectangular); + num++; + var cLoop = new CurveLoop(); + var crvArr = (CurveArray)enumCurveLoops.Current; + var enumCurves = crvArr.GetEnumerator(); + for (; enumCurves.MoveNext();) + { + var crv = (Autodesk.Revit.DB.Curve)enumCurves.Current; + cLoop.Append(crv); + } + if (!cLoop.HasPlane()) + throw new Exception(Properties.Resources.CurtainPanelIsNotRectangular); + if (!cLoop.IsRectangular(cLoop.GetPlane())) + throw new Exception(Properties.Resources.CurtainPanelIsNotRectangular); + result = cLoop.GetRectangularHeight(cLoop.GetPlane()); + } + return result * UnitConverter.HostToDynamoFactor(SpecTypeId.Length); } - return result * UnitConverter.HostToDynamoFactor(SpecTypeId.Length); - } - } - /// - /// Gets the height of the specific curtain panel, if it's rectangular - /// - public double Height - { - get - { - var enumCurveLoops = PanelBoundaries.GetEnumerator(); - int num = 0; - double result = 0.0; - for (; enumCurveLoops.MoveNext();) + } + + #endregion + + #region Private constructors + + /// + /// Create from an existing Revit Element + /// + /// + protected CurtainPanel(Autodesk.Revit.DB.Panel panelElement) + { + SafeInit(() => InitCurtainPanel(panelElement), true); + } + + #endregion + + #region Helper for private constructors + + /// + /// Initialize a CurtainPanel element + /// + /// + private void InitCurtainPanel(Autodesk.Revit.DB.Panel panelElement) + { + InternalSetFamilyInstance(panelElement); + boundsCache = null; + } + + #endregion + + #region Static constructors + + /// + ///get curtain panel from element + /// + /// + + internal static CurtainPanel ByElement(CurtainPanel panelElement) + { + var elementAsPanel = panelElement.InternalElement as Autodesk.Revit.DB.Panel; + if (elementAsPanel == null) + throw new Exception("Curtain Panel should represent Revit panel"); + return new CurtainPanel(elementAsPanel); + } + + /// + ///get all panels of curtain wall, system or slope glazing roof + /// + /// + public static CurtainPanel[] ByElement(Element hostingElement) + { + CurtainGridSet thisSet = CurtainGrid.AllCurtainGrids(hostingElement.InternalElement); + var result = new List(); + + var enumGrid = thisSet.GetEnumerator(); + for (; enumGrid.MoveNext();) { - if (num > 0) - throw new Exception(Properties.Resources.CurtainPanelIsNotRectangular); - num++; - var cLoop = new CurveLoop(); - var crvArr = (CurveArray) enumCurveLoops.Current; - var enumCurves = crvArr.GetEnumerator(); - for (; enumCurves.MoveNext();) - { - var crv = (Autodesk.Revit.DB.Curve) enumCurves.Current; - cLoop.Append(crv); - } - if (!cLoop.HasPlane()) - throw new Exception(Properties.Resources.CurtainPanelIsNotRectangular); - if (!cLoop.IsRectangular(cLoop.GetPlane())) - throw new Exception(Properties.Resources.CurtainPanelIsNotRectangular); - result = cLoop.GetRectangularHeight(cLoop.GetPlane()); + var grid = (Autodesk.Revit.DB.CurtainGrid)enumGrid.Current; + var ids = grid.GetPanelIds(); + var idEnum = ids.GetEnumerator(); + for (; idEnum.MoveNext();) + { + var idPanel = idEnum.Current; + var panel = DocumentManager.Instance.CurrentDBDocument.GetElement(idPanel); + if (panel is Autodesk.Revit.DB.Panel) + { + result.Add(CurtainPanel.FromExisting(panel as Autodesk.Revit.DB.Panel, true)); + } + else + { + result.Add(null); + } + + } } - return result * UnitConverter.HostToDynamoFactor(SpecTypeId.Length); - } - } - - #endregion - - #region Private constructors - - /// - /// Create from an existing Revit Element - /// - /// - protected CurtainPanel(Autodesk.Revit.DB.Panel panelElement) - { - SafeInit(() => InitCurtainPanel(panelElement), true); - } - - #endregion - - #region Helper for private constructors - - /// - /// Initialize a CurtainPanel element - /// - /// - private void InitCurtainPanel(Autodesk.Revit.DB.Panel panelElement) - { - InternalSetFamilyInstance(panelElement); - boundsCache = null; - } - - #endregion - - #region Static constructors - - /// - ///get curtain panel from element - /// - /// - - internal static CurtainPanel ByElement(CurtainPanel panelElement) - { - var elementAsPanel = panelElement.InternalElement as Autodesk.Revit.DB.Panel; - if (elementAsPanel == null) - throw new Exception("Curtain Panel should represent Revit panel"); - return new CurtainPanel(elementAsPanel); - } - - /// - ///get all panels of curtain wall, system or slope glazing roof - /// - /// - public static CurtainPanel[] ByElement(Element hostingElement) - { - CurtainGridSet thisSet = CurtainGrid.AllCurtainGrids(hostingElement.InternalElement); - var result = new List(); - - var enumGrid = thisSet.GetEnumerator(); - for (; enumGrid.MoveNext(); ) - { - var grid = (Autodesk.Revit.DB.CurtainGrid)enumGrid.Current; - var ids = grid.GetPanelIds(); - var idEnum = ids.GetEnumerator(); - for (; idEnum.MoveNext(); ) + return result.ToArray(); + } + + /// + /// Construct this type from an existing Revit element. + /// + /// + /// + /// + internal static CurtainPanel FromExisting(Autodesk.Revit.DB.Panel panel, bool isRevitOwned) + { + if (panel == null) { - var idPanel = idEnum.Current; - var panel = DocumentManager.Instance.CurrentDBDocument.GetElement(idPanel); - result.Add(CurtainPanel.FromExisting(panel as Autodesk.Revit.DB.Panel, true)); + throw new ArgumentNullException("panel"); } - } - return result.ToArray(); - } - - /// - /// Construct this type from an existing Revit element. - /// - /// - /// - /// - internal static CurtainPanel FromExisting(Autodesk.Revit.DB.Panel panel, bool isRevitOwned) - { - if (panel == null) - { - throw new ArgumentNullException("panel"); - } - - return new CurtainPanel(panel) - { - IsRevitOwned = true //making panels in Dynamo is not implemented - }; - } - - #endregion - - #region public methods - /// - /// Gets Mullions hosting the specified curtain panel - /// - /// - public Mullion[] SupportingMullions() - { - var elementAsPanel = InternalElement as Autodesk.Revit.DB.Panel; - if (elementAsPanel == null) - throw new Exception(Properties.Resources.CurtainPanelShouldRepresentRevitPanel); - var bounds = this.Boundaries; - - var host = elementAsPanel.Host; - - //var hostingGrid = CurtainGrid.ByElement(UnknownElement.FromExisting(host)); - - var mullions = Mullion.ByElement(UnknownElement.FromExisting(host, true));//hostingGrid.GetMullions(); - int numberMullions = mullions.Length; - var result = new List(); - - for (int index = 0; index < numberMullions; index++) - { - var mullionAtIndex = mullions[index] as Mullion; - if (mullionAtIndex == null) - continue; - - var thisCurve = mullionAtIndex.LocationCurve; - - var enumBounds = bounds.GetEnumerator(); - bool neighbor = false; - for (; enumBounds.MoveNext() && !neighbor; ) + + return new CurtainPanel(panel) + { + IsRevitOwned = true //making panels in Dynamo is not implemented + }; + } + + #endregion + + #region public methods + /// + /// Gets Mullions hosting the specified curtain panel + /// + /// + public Mullion[] SupportingMullions() + { + var elementAsPanel = InternalElement as Autodesk.Revit.DB.Panel; + if (elementAsPanel == null) + throw new Exception(Properties.Resources.CurtainPanelShouldRepresentRevitPanel); + var bounds = this.Boundaries; + + var host = elementAsPanel.Host; + + //var hostingGrid = CurtainGrid.ByElement(UnknownElement.FromExisting(host)); + + var mullions = Mullion.ByElement(UnknownElement.FromExisting(host, true));//hostingGrid.GetMullions(); + int numberMullions = mullions.Length; + var result = new List(); + + for (int index = 0; index < numberMullions; index++) { - var polycrv = enumBounds.Current as PolyCurve; - if (polycrv == null) - continue; - var bndCrvs = polycrv.Curves(); - var enumCrv = bndCrvs.GetEnumerator(); - for (; enumCrv.MoveNext(); ) - { - var crv = enumCrv.Current as Autodesk.DesignScript.Geometry.Curve; - if (crv == null) - continue; - var midPoint = crv.PointAtParameter(0.5); - if (midPoint.DistanceTo(thisCurve) < 1.0e-7) - { - neighbor = true; - break; - } - } + var mullionAtIndex = mullions[index] as Mullion; + if (mullionAtIndex == null) + continue; + + var thisCurve = mullionAtIndex.LocationCurve; + + var enumBounds = bounds.GetEnumerator(); + bool neighbor = false; + for (; enumBounds.MoveNext() && !neighbor;) + { + var polycrv = enumBounds.Current as PolyCurve; + if (polycrv == null) + continue; + var bndCrvs = polycrv.Curves(); + var enumCrv = bndCrvs.GetEnumerator(); + for (; enumCrv.MoveNext();) + { + var crv = enumCrv.Current as Autodesk.DesignScript.Geometry.Curve; + if (crv == null) + continue; + var midPoint = crv.PointAtParameter(0.5); + if (midPoint.DistanceTo(thisCurve) < 1.0e-7) + { + neighbor = true; + break; + } + } + } + if (neighbor) + result.Add(mullionAtIndex); } - if (neighbor) - result.Add(mullionAtIndex); - } - return result.ToArray(); - } - /// - /// Gets family instance from curtain Panel - /// - /// - public FamilyInstance AsFamilyInstance() - { - return FamilyInstance.FromExisting(InternalElement as Autodesk.Revit.DB.FamilyInstance, true); - } - - public override string ToString() - { - return "Curtain Panel"; - } - - #endregion - - } + return result.ToArray(); + } + /// + /// Gets family instance from curtain Panel + /// + /// + public FamilyInstance AsFamilyInstance() + { + return FamilyInstance.FromExisting(InternalElement as Autodesk.Revit.DB.FamilyInstance, true); + } + + public override string ToString() + { + return "Curtain Panel"; + } + + #endregion + + } } \ No newline at end of file