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


C# FilteredElementCollector.GetFamilySymbolIds方法代码示例

本文整理汇总了C#中FilteredElementCollector.GetFamilySymbolIds方法的典型用法代码示例。如果您正苦于以下问题:C# FilteredElementCollector.GetFamilySymbolIds方法的具体用法?C# FilteredElementCollector.GetFamilySymbolIds怎么用?C# FilteredElementCollector.GetFamilySymbolIds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FilteredElementCollector的用法示例。


在下文中一共展示了FilteredElementCollector.GetFamilySymbolIds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute


//.........这里部分代码省略.........
            // This obviously invalidates the uidoc
            // instance on the previously open document.
            //uiapp.OpenAndActivateDocument( filename );
              }
            }
              }
              #endregion // Create a new structural stiffener family

              #region Load the structural stiffener family

              // Must be outside transaction; otherwise Revit
              // throws InvalidOperationException: The document
              // must not be modifiable before calling LoadFamily.
              // Any open transaction must be closed prior the call.

              // Calling this without a prior call to SaveAs
              // caused a "serious error" in Revit 2012:

              family = fdoc.LoadFamily( doc );

              // Workaround for Revit 2012,
              // no longer needed in Revit 2014:

              //doc.LoadFamily( filename, out family );

              // Setting the name requires an open
              // transaction, of course.

              //family.Name = _family_name;

              FamilySymbol symbol = null;

              foreach( ElementId id
            in family.GetFamilySymbolIds() )
              {
            // Our family only contains one
            // symbol, so pick it and leave.

            symbol = doc.GetElement( id ) as FamilySymbol;

            break;
              }
              #endregion // Load the structural stiffener family

              #region Insert stiffener family instance

              using( t = new Transaction( doc ) )
              {
            t.Start( "Insert structural stiffener family instance" );

            // Setting the name requires an open
            // transaction, of course.

            family.Name = _family_name;
            symbol.Name = _family_name;

            // Need to activate symbol before
            // using it in Revit 2016.

            symbol.Activate();

            bool useSimpleInsertionPoint = true;

            if( useSimpleInsertionPoint )
            {
              //Plane plane = app.Create.NewPlane( new XYZ( 1, 2, 3 ), XYZ.Zero );
开发者ID:jeremytammik,项目名称:Stiffener,代码行数:67,代码来源:Command.cs

示例2: CreateFaceWalls

        static void CreateFaceWalls(
            Document doc)
        {
            Application app = doc.Application;

              Document massDoc = app.NewFamilyDocument(
            _conceptual_mass_template_path );

              CreateMassExtrusion( massDoc );

              //if( File.Exists( _family_path ) )
              //  File.Delete( _family_path );

              SaveAsOptions opt = new SaveAsOptions();
              opt.OverwriteExistingFile = true;

              massDoc.SaveAs( _family_path, opt );

              using( Transaction tx = new Transaction( doc ) )
              {
            tx.Start( "Create FaceWall" );

            if( !doc.LoadFamily( _family_path ) )
              throw new Exception( "DID NOT LOAD FAMILY" );

            Family family = new FilteredElementCollector( doc )
              .OfClass( typeof( Family ) )
              .Where<Element>( x => x.Name.Equals( _family_name ) )
              .Cast<Family>()
              .FirstOrDefault();

            FamilySymbol fs = doc.GetElement(
              family.GetFamilySymbolIds().First<ElementId>() )
            as FamilySymbol;

            // Create a family instance

            Level level = doc.ActiveView.GenLevel;

            FamilyInstance fi = doc.Create.NewFamilyInstance(
              XYZ.Zero, fs, level, StructuralType.NonStructural );

            doc.Regenerate(); // required to generate the geometry!

            // Determine wall type.

            WallType wallType = new FilteredElementCollector( doc )
              .OfClass( typeof( WallType ) )
              .Cast<WallType>()
              .Where<WallType>( x => FaceWall.IsWallTypeValidForFaceWall( doc, x.Id ) )
              .FirstOrDefault();

            // Retrieve mass element geometry.

            Options options = app.Create.NewGeometryOptions();
            options.ComputeReferences = true;

            //options.View = doc.ActiveView; // conceptual mass is not visible in default view

            GeometryElement geo = fi.get_Geometry( options );

            // Create a sloped wall from the geometry.

            foreach( GeometryObject obj in geo )
            {
              Solid solid = obj as Solid;

              if( null != solid )
              {
            foreach( Face f in solid.Faces )
            {
              Debug.Assert( null != f.Reference,
                "we asked for references, didn't we?" );

              PlanarFace pf = f as PlanarFace;

              if( null != pf )
              {
                XYZ v = pf.FaceNormal;

                // Errors:
                //
                // Could not create a face wall.
                //
                // Caused by using ActiveView.Level
                // instead of ActiveView.GenLevel.
                //
                // This reference cannot be applied to a face wall.
                //
                // Caused by using this on a horizontal face.

                if( !Util.IsVertical( v ) )
                {
                  FaceWall.Create(
                    doc, wallType.Id,
                    WallLocationLine.CoreCenterline,
                    f.Reference );
                }
              }
            }
//.........这里部分代码省略.........
开发者ID:sridharbaldava,项目名称:the_building_coder_samples,代码行数:101,代码来源:CmdFaceWall.cs


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