本文整理汇总了C#中FilteredElementCollector.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# FilteredElementCollector.Sort方法的具体用法?C# FilteredElementCollector.Sort怎么用?C# FilteredElementCollector.Sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilteredElementCollector
的用法示例。
在下文中一共展示了FilteredElementCollector.Sort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
Result commandResult = Result.Succeeded;
try
{
UIApplication uiApp = commandData.Application;
UIDocument uiDoc = uiApp.ActiveUIDocument;
Document dbDoc = uiDoc.Document;
View view = uiDoc.ActiveGraphicalView;
XYZ pLoc = XYZ.Zero;
try
{
pLoc = uiDoc.Selection.PickPoint(
"Please pick text insertion point" );
}
catch( Autodesk.Revit.Exceptions.OperationCanceledException )
{
Debug.WriteLine( "Operation cancelled." );
message = "Operation cancelled.";
return Result.Succeeded;
}
List<TextNoteType> noteTypeList
= new FilteredElementCollector( dbDoc )
.OfClass( typeof( TextNoteType ) )
.Cast<TextNoteType>()
.ToList();
// Sort note types into ascending text size
BuiltInParameter bipTextSize
= BuiltInParameter.TEXT_SIZE;
noteTypeList.Sort( ( a, b )
=> a.get_Parameter( bipTextSize ).AsDouble()
.CompareTo(
b.get_Parameter( bipTextSize ).AsDouble() ) );
foreach( TextNoteType textType in noteTypeList )
{
Debug.WriteLine( textType.Name );
Parameter paramTextFont
= textType.get_Parameter(
BuiltInParameter.TEXT_FONT );
Parameter paramTextSize
= textType.get_Parameter(
BuiltInParameter.TEXT_SIZE );
Parameter paramBorderSize
= textType.get_Parameter(
BuiltInParameter.LEADER_OFFSET_SHEET );
Parameter paramTextBold
= textType.get_Parameter(
BuiltInParameter.TEXT_STYLE_BOLD );
Parameter paramTextItalic
= textType.get_Parameter(
BuiltInParameter.TEXT_STYLE_ITALIC );
Parameter paramTextUnderline
= textType.get_Parameter(
BuiltInParameter.TEXT_STYLE_UNDERLINE );
Parameter paramTextWidthScale
= textType.get_Parameter(
BuiltInParameter.TEXT_WIDTH_SCALE );
string fontName = paramTextFont.AsString();
double textHeight = paramTextSize.AsDouble();
bool textBold = paramTextBold.AsInteger() == 1
? true : false;
bool textItalic = paramTextItalic.AsInteger() == 1
? true : false;
bool textUnderline = paramTextUnderline.AsInteger() == 1
? true : false;
double textBorder = paramBorderSize.AsDouble();
double textWidthScale = paramTextWidthScale.AsDouble();
FontStyle textStyle = FontStyle.Regular;
if( textBold )
{
textStyle |= FontStyle.Bold;
}
//.........这里部分代码省略.........