public Result ExecuteObsolete(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication app = commandData.Application;
UIDocument uidoc = app.ActiveUIDocument;
Document doc = uidoc.Document;
BindingMap bindings = doc.ParameterBindings;
//Dictionary<string, Guid> guids = new Dictionary<string, Guid>();
Dictionary<Definition, object> mapDefToGuid = new Dictionary<Definition, object>();
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;
if( d is ExternalDefinition )
{
Guid g = ( (ExternalDefinition) d ).GUID;
Debug.Print( d.Name + ": " + g.ToString() );
mapDefToGuid.Add( d, g );
}
else
{
Debug.Assert( d is InternalDefinition );
// this built-in parameter is INVALID:
BuiltInParameter bip = ( (InternalDefinition) d ).BuiltInParameter;
Debug.Print( d.Name + ": " + bip.ToString() );
// if have a definition file and group name, we can still determine the GUID:
//Guid g = SharedParamGuid( app, "Identity data", d.Name );
mapDefToGuid.Add( d, null );
}
}
}
List<Element> walls = new List<Element>();
if( !Util.GetSelectedElementsOrAll(
walls, uidoc, typeof( Wall ) ) )
{
Selection sel = uidoc.Selection;
message = ( 0 < sel.GetElementIds().Count )
? "Please select some wall elements."
: "No wall elements found.";
}
else
{
//List<string> keys = new List<string>( mapDefToGuid.Keys );
//keys.Sort();
foreach( Wall wall in walls )
{
Debug.Print( Util.ElementDescription( wall ) );
foreach( Definition d in mapDefToGuid.Keys )
{
object o = mapDefToGuid[d];
Parameter p = ( null == o )
? wall.get_Parameter( d )
: wall.get_Parameter( (Guid) o );
string s = ( null == p )
? "<null>"
: p.AsValueString();
Debug.Print( d.Name + ": " + s );
}
}
}
return Result.Failed;
}