本文整理汇总了C#中ElementSet.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# ElementSet.Clear方法的具体用法?C# ElementSet.Clear怎么用?C# ElementSet.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElementSet
的用法示例。
在下文中一共展示了ElementSet.Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
#region 1.2.a. Examine command data input argument:
//
// access application, document, and current view:
//
UIApplication uiapp = commandData.Application;
Application app = uiapp.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;
View view = commandData.View;
LanguageType lt = app.Language;
ProductType pt = app.Product;
string s = "Application = " + app.VersionName
+ "\r\nLanguage = " + lt.ToString()
+ "\r\nProduct = " + pt.ToString()
+ "\r\nVersion = " + app.VersionNumber
+ "\r\nDocument path = " + doc.PathName // empty if not yet saved
+ "\r\nDocument title = " + doc.Title
+ "\r\nView name = " + view.Name;
LabUtils.InfoMsg( s );
#endregion // 1.2.a. Examine command data input argument
#region 1.2.b. List selection set content:
//
// list the current selection set:
//
Selection sel = uidoc.Selection;
List<string> a = new List<string>();
foreach( ElementId id in sel.GetElementIds() )
{
Element e = doc.GetElement( id );
string name = ( null == e.Category )
? e.GetType().Name
: e.Category.Name;
a.Add( name + " Id="
+ e.Id.IntegerValue.ToString() );
}
LabUtils.InfoMsg(
"There are {0} element{1} in the selection set{2}",
a );
#endregion // 1.2.b. List selection set content
#region 1.2.c. Populate return arguments:
// We pretend that something is wrong with the
// first element in the selection. Pass an error
// message back to the user and indicate the
// error result:
ICollection<ElementId> ids = sel.GetElementIds();
if( 0 < ids.Count )
{
//ElementSetIterator iter = sel.Elements.ForwardIterator();
//iter.MoveNext();
//Element errElem = iter.Current as Element;
Element errElem = doc.GetElement( ids.First() );
elements.Clear();
elements.Insert( errElem );
message = "We pretend something is wrong with this "
+ " element and pass back this message to user";
return Result.Failed;
}
else
{
// We return failed here as well.
// As long as the message string and element set are empty,
// it makes no difference to the user.
// If they are not empty, the message is displayed to the
// user and/or the elements in the set are highlighted.
// If an automatic transaction is open, it is aborted,
// avoiding marking the database as dirty.
return Result.Failed;
}
#endregion // 1.2.c. Populate return arguments
}