当前位置: 首页>>代码示例>>C#>>正文


C# FilteredElementCollector.Sort方法代码示例

本文整理汇总了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;
              }
//.........这里部分代码省略.........
开发者ID:jeremytammik,项目名称:the_building_coder_samples,代码行数:101,代码来源:CmdNewTextNote.cs


注:本文中的FilteredElementCollector.Sort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。