forked from jeremytammik/RevitLookup
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jeremytammik#215 from SergeyNefyodov/dev-curtain-w…
…alls-support Add support for Panels and Curtain Grids
- Loading branch information
Showing
5 changed files
with
165 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
source/RevitLookup/Core/ComponentModel/Descriptors/CurtainGridDescriptor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2003-2024 by Autodesk, Inc. | ||
// | ||
// Permission to use, copy, modify, and distribute this software in | ||
// object code form for any purpose and without fee is hereby granted, | ||
// provided that the above copyright notice appears in all copies and | ||
// that both that copyright notice and the limited warranty and | ||
// restricted rights notice below appear in all supporting | ||
// documentation. | ||
// | ||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. | ||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF | ||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. | ||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE | ||
// UNINTERRUPTED OR ERROR FREE. | ||
// | ||
// Use, duplication, or disclosure by the U.S. Government is subject to | ||
// restrictions set forth in FAR 52.227-19 (Commercial Computer | ||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) | ||
// (Rights in Technical Data and Computer Software), as applicable. | ||
|
||
using System.Reflection; | ||
using RevitLookup.Core.Contracts; | ||
using RevitLookup.Core.Objects; | ||
|
||
namespace RevitLookup.Core.ComponentModel.Descriptors; | ||
|
||
public class CurtainGridDescriptor(CurtainGrid curtainGrid) : Descriptor, IDescriptorResolver | ||
{ | ||
public ResolveSet Resolve(Document context, string target, ParameterInfo[] parameters) | ||
{ | ||
return target switch | ||
{ | ||
nameof(CurtainGrid.GetCell) => ResolveCells(), | ||
nameof(CurtainGrid.GetPanel) => ResolvePanels(), | ||
_ => null | ||
}; | ||
|
||
ResolveSet ResolveCells() | ||
{ | ||
var uLinesIds = (List<ElementId>) curtainGrid.GetUGridLineIds(); | ||
var vLinesIds = (List<ElementId>) curtainGrid.GetVGridLineIds(); | ||
uLinesIds.Add(ElementId.InvalidElementId); | ||
vLinesIds.Add(ElementId.InvalidElementId); | ||
var capacity = uLinesIds.Count * vLinesIds.Count; | ||
|
||
var resolveSummary = new ResolveSet(capacity); | ||
foreach (var uLineId in uLinesIds) | ||
{ | ||
foreach (var vLineId in vLinesIds) | ||
{ | ||
var cell = curtainGrid.GetCell(uLineId, vLineId); | ||
resolveSummary.AppendVariant(cell, $"U: {uLineId}, V: {vLineId}"); | ||
} | ||
} | ||
|
||
return resolveSummary; | ||
} | ||
|
||
ResolveSet ResolvePanels() | ||
{ | ||
var uLinesIds = (List<ElementId>) curtainGrid.GetUGridLineIds(); | ||
var vLinesIds = (List<ElementId>) curtainGrid.GetVGridLineIds(); | ||
uLinesIds.Add(ElementId.InvalidElementId); | ||
vLinesIds.Add(ElementId.InvalidElementId); | ||
var capacity = uLinesIds.Count * vLinesIds.Count; | ||
|
||
var resolveSummary = new ResolveSet(capacity); | ||
foreach (var uLineId in uLinesIds) | ||
{ | ||
foreach (var vLineId in vLinesIds) | ||
{ | ||
var panel = curtainGrid.GetPanel(uLineId, vLineId); | ||
resolveSummary.AppendVariant(panel, $"U: {uLineId}, V: {vLineId} - {panel.Name}, ID{panel.Id}"); | ||
} | ||
} | ||
|
||
return resolveSummary; | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
source/RevitLookup/Core/ComponentModel/Descriptors/PanelDescriptor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2003-2024 by Autodesk, Inc. | ||
// | ||
// Permission to use, copy, modify, and distribute this software in | ||
// object code form for any purpose and without fee is hereby granted, | ||
// provided that the above copyright notice appears in all copies and | ||
// that both that copyright notice and the limited warranty and | ||
// restricted rights notice below appear in all supporting | ||
// documentation. | ||
// | ||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. | ||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF | ||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. | ||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE | ||
// UNINTERRUPTED OR ERROR FREE. | ||
// | ||
// Use, duplication, or disclosure by the U.S. Government is subject to | ||
// restrictions set forth in FAR 52.227-19 (Commercial Computer | ||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) | ||
// (Rights in Technical Data and Computer Software), as applicable. | ||
|
||
using System.Reflection; | ||
using RevitLookup.Core.Contracts; | ||
using RevitLookup.Core.Objects; | ||
|
||
namespace RevitLookup.Core.ComponentModel.Descriptors; | ||
|
||
public class PanelDescriptor(Panel panel) : Descriptor, IDescriptorResolver | ||
{ | ||
public ResolveSet Resolve(Document context, string target, ParameterInfo[] parameters) | ||
{ | ||
return target switch | ||
{ | ||
nameof(Panel.GetRefGridLines) => ResolveGridLines(), | ||
_ => null | ||
}; | ||
|
||
ResolveSet ResolveGridLines() | ||
{ | ||
ElementId uId = null; | ||
ElementId vId = null; | ||
panel.GetRefGridLines(ref uId, ref vId); | ||
|
||
var resolveSummary = new ResolveSet(2); | ||
resolveSummary.AppendVariant(uId); | ||
resolveSummary.AppendVariant(vId); | ||
return resolveSummary; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters