Skip to content

Commit

Permalink
reimplemented CmdListSharedParams to classify instance versus type sh…
Browse files Browse the repository at this point in the history
…ared param definitions
  • Loading branch information
Jeremy Tammik committed Nov 21, 2013
1 parent 54679bf commit c7d7553
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 6 deletions.
4 changes: 2 additions & 2 deletions BuildingCoder/BuildingCoder/CmdDutAbbreviation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ DisplayUnitType n

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

string unit_types, valid_unit_symbols;
Expand Down
56 changes: 54 additions & 2 deletions BuildingCoder/BuildingCoder/CmdListSharedParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace BuildingCoder
[Transaction( TransactionMode.ReadOnly )]
class CmdListSharedParams : IExternalCommand
{
#region Obsolete code that was never used
/// <summary>
/// Get GUID for a given shared param name.
/// </summary>
Expand All @@ -48,8 +49,7 @@ static Guid SharedParamGuid( Application app, string defGroup, string defName )
return guid;
}


public Result Execute(
public Result ExecuteObsolete(
ExternalCommandData commandData,
ref string message,
ElementSet elements )
Expand Down Expand Up @@ -135,5 +135,57 @@ DefinitionBindingMapIterator it
}
return Result.Failed;
}
#endregion // Obsolete code that was never used

public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements )
{
UIApplication app = commandData.Application;
UIDocument uidoc = app.ActiveUIDocument;
Document doc = uidoc.Document;

BindingMap bindings = doc.ParameterBindings;

int n = bindings.Size;

Debug.Print( "{0} shared parementer{1} defined{2}",
n, Util.PluralSuffix( n ), Util.DotOrColon( n ) );

if( 0 < n )
{
DefinitionBindingMapIterator it
= bindings.ForwardIterator();

while( it.MoveNext() )
{
Definition d = it.Key as Definition;
Binding b = it.Current as Binding;

Debug.Assert( b is ElementBinding,
"all Binding instances are ElementBinding instances" );

Debug.Assert( b is InstanceBinding
|| b is TypeBinding,
"all bindings are either instance or type" );

// All definitions obtained in this manner
// are InternalDefinition instances, even
// if they are actually associated with
// shared parameters, i.e. external.

Debug.Assert( d is InternalDefinition,
"all definitions obtained from BindingMap are internal" );

string sbinding = ( b is InstanceBinding )
? "instance"
: "type";

Debug.Print( "{0}: {1}", d.Name, sbinding );
}
}
return Result.Succeeded;
}
}
}
4 changes: 2 additions & 2 deletions BuildingCoder/BuildingCoder/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion( "2014.0.105.2" )]
[assembly: AssemblyFileVersion( "2014.0.105.2" )]
[assembly: AssemblyVersion( "2014.0.105.3" )]
[assembly: AssemblyFileVersion( "2014.0.105.3" )]

0 comments on commit c7d7553

Please sign in to comment.