-
Notifications
You must be signed in to change notification settings - Fork 300
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 #233 from SergeyNefyodov/dev-family-size-tables-su…
…pport Add FamilySizeTable support
- Loading branch information
Showing
8 changed files
with
205 additions
and
15 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
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
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
31 changes: 31 additions & 0 deletions
31
source/RevitLookup/Core/ComponentModel/Descriptors/FamilySizeTableColumnDescriptor.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,31 @@ | ||
// 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 RevitLookup.Core.Objects; | ||
|
||
namespace RevitLookup.Core.ComponentModel.Descriptors; | ||
|
||
public sealed class FamilySizeTableColumnDescriptor : Descriptor | ||
{ | ||
public FamilySizeTableColumnDescriptor(FamilySizeTableColumn column) | ||
{ | ||
Name = column.Name; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
source/RevitLookup/Core/ComponentModel/Descriptors/FamilySizeTableDescriptor.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,65 @@ | ||
// 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 sealed class FamilySizeTableDescriptor(FamilySizeTable table) : Descriptor, IDescriptorResolver | ||
{ | ||
public IVariants Resolve(Document context, string target, ParameterInfo[] parameters) | ||
{ | ||
return target switch | ||
{ | ||
nameof(FamilySizeTable.GetColumnHeader) => ResolveColumnHeader(), | ||
nameof(FamilySizeTable.IsValidColumnIndex) => ResolveIsValidColumnIndex(), | ||
_ => null | ||
}; | ||
|
||
IVariants ResolveColumnHeader() | ||
{ | ||
var count = table.NumberOfColumns; | ||
var variants = new Variants<FamilySizeTableColumn>(count); | ||
|
||
for (var i = 0; i < count; i++) | ||
{ | ||
variants.Add(table.GetColumnHeader(i)); | ||
} | ||
|
||
return variants; | ||
} | ||
|
||
IVariants ResolveIsValidColumnIndex() | ||
{ | ||
var count = table.NumberOfColumns; | ||
var variants = new Variants<bool>(count); | ||
|
||
for (var i = 0; i <= count; i++) | ||
{ | ||
var result = table.IsValidColumnIndex(i); | ||
variants.Add(result, $"{i}: {result}"); | ||
} | ||
|
||
return variants; | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
source/RevitLookup/Core/ComponentModel/Descriptors/FamilySizeTableManagerDescriptor.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,66 @@ | ||
// 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 sealed class FamilySizeTableManagerDescriptor(FamilySizeTableManager manager) : Descriptor, IDescriptorResolver | ||
{ | ||
public IVariants Resolve(Document context, string target, ParameterInfo[] parameters) | ||
{ | ||
return target switch | ||
{ | ||
nameof(FamilySizeTableManager.GetSizeTable) => ResolveSizeTable(), | ||
nameof(FamilySizeTableManager.HasSizeTable) => ResolveHasSizeTable(), | ||
nameof(FamilySizeTableManager.GetFamilySizeTableManager) => Variants.Single(manager), | ||
_ => null | ||
}; | ||
|
||
IVariants ResolveSizeTable() | ||
{ | ||
var names = manager.GetAllSizeTableNames(); | ||
var variants = new Variants<FamilySizeTable>(names.Count); | ||
|
||
foreach (var name in names) | ||
{ | ||
variants.Add(manager.GetSizeTable(name), name); | ||
} | ||
|
||
return variants; | ||
} | ||
|
||
IVariants ResolveHasSizeTable() | ||
{ | ||
var names = manager.GetAllSizeTableNames(); | ||
var variants = new Variants<bool>(names.Count); | ||
|
||
foreach (var name in names) | ||
{ | ||
var result = manager.HasSizeTable(name); | ||
variants.Add(result, $"{name}: {result}"); | ||
} | ||
|
||
return variants; | ||
} | ||
} | ||
} |