Skip to content

Commit c7d7553

Browse files
author
Jeremy Tammik
committed
reimplemented CmdListSharedParams to classify instance versus type shared param definitions
1 parent 54679bf commit c7d7553

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
lines changed

BuildingCoder/BuildingCoder/CmdDutAbbreviation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ DisplayUnitType n
119119

120120
Debug.Print( "Here is a list of the first {0} "
121121
+ "display unit types with official Revit API "
122-
+ "LabelUtils and hard-coded The Building Coder "
123-
+ "abbreviations and the valid unit symbols:\n",
122+
+ "LabelUtils, hard-coded The Building Coder "
123+
+ "abbreviations and valid unit symbols:\n",
124124
(int) n - 1 );
125125

126126
string unit_types, valid_unit_symbols;

BuildingCoder/BuildingCoder/CmdListSharedParams.cs

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace BuildingCoder
2424
[Transaction( TransactionMode.ReadOnly )]
2525
class CmdListSharedParams : IExternalCommand
2626
{
27+
#region Obsolete code that was never used
2728
/// <summary>
2829
/// Get GUID for a given shared param name.
2930
/// </summary>
@@ -48,8 +49,7 @@ static Guid SharedParamGuid( Application app, string defGroup, string defName )
4849
return guid;
4950
}
5051

51-
52-
public Result Execute(
52+
public Result ExecuteObsolete(
5353
ExternalCommandData commandData,
5454
ref string message,
5555
ElementSet elements )
@@ -135,5 +135,57 @@ DefinitionBindingMapIterator it
135135
}
136136
return Result.Failed;
137137
}
138+
#endregion // Obsolete code that was never used
139+
140+
public Result Execute(
141+
ExternalCommandData commandData,
142+
ref string message,
143+
ElementSet elements )
144+
{
145+
UIApplication app = commandData.Application;
146+
UIDocument uidoc = app.ActiveUIDocument;
147+
Document doc = uidoc.Document;
148+
149+
BindingMap bindings = doc.ParameterBindings;
150+
151+
int n = bindings.Size;
152+
153+
Debug.Print( "{0} shared parementer{1} defined{2}",
154+
n, Util.PluralSuffix( n ), Util.DotOrColon( n ) );
155+
156+
if( 0 < n )
157+
{
158+
DefinitionBindingMapIterator it
159+
= bindings.ForwardIterator();
160+
161+
while( it.MoveNext() )
162+
{
163+
Definition d = it.Key as Definition;
164+
Binding b = it.Current as Binding;
165+
166+
Debug.Assert( b is ElementBinding,
167+
"all Binding instances are ElementBinding instances" );
168+
169+
Debug.Assert( b is InstanceBinding
170+
|| b is TypeBinding,
171+
"all bindings are either instance or type" );
172+
173+
// All definitions obtained in this manner
174+
// are InternalDefinition instances, even
175+
// if they are actually associated with
176+
// shared parameters, i.e. external.
177+
178+
Debug.Assert( d is InternalDefinition,
179+
"all definitions obtained from BindingMap are internal" );
180+
181+
string sbinding = ( b is InstanceBinding )
182+
? "instance"
183+
: "type";
184+
185+
Debug.Print( "{0}: {1}", d.Name, sbinding );
186+
}
187+
}
188+
return Result.Succeeded;
189+
}
138190
}
139191
}

BuildingCoder/BuildingCoder/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
//
3232
// You can specify all the values or you can default the Revision and Build Numbers
3333
// by using the '*' as shown below:
34-
[assembly: AssemblyVersion( "2014.0.105.2" )]
35-
[assembly: AssemblyFileVersion( "2014.0.105.2" )]
34+
[assembly: AssemblyVersion( "2014.0.105.3" )]
35+
[assembly: AssemblyFileVersion( "2014.0.105.3" )]

0 commit comments

Comments
 (0)