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


C# Element.GetEntity方法代码示例

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


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

示例1: ProjectSettingsManager

        private ProjectSettingsManager(Document document)
        {
            var col = new FilteredElementCollector(document).OfClass(typeof(ProjectInfo));
            _element = col.ToElements().First();
            _schema = Schema.Lookup(_schemaGuid) ?? GetStorageSchema();

            //get entity from element if it exists in there already or create new otherwise
            _entity = _element.GetEntity(_schema);
            if (_entity == null || _entity.Schema == null)
                _entity = new Entity(_schema);

            LoadData(document);

            //static cache management
            Cache.Add(document, this);
            document.DocumentClosing += new EventHandler<DocumentClosingEventArgs>(OnDocumentClosing);
            document.Application.DocumentSynchronizedWithCentral += new EventHandler<DocumentSynchronizedWithCentralEventArgs>(OnDocumentSynchronized);
            document.Application.DocumentChanged += new EventHandler<DocumentChangedEventArgs>((sender, args) =>
                {
                    if (args.Operation == UndoOperation.TransactionUndone || args.Operation == UndoOperation.TransactionRedone)
                    {

                    }
                });
        }
开发者ID:martin1cerny,项目名称:BIM-Library-CZ-Revit,代码行数:25,代码来源:ProjectSettingsManager.cs

示例2: Stream

        private void Stream( ArrayList data, Element elem )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( Element ) ) );

              try
              {
            data.Add( new Snoop.Data.String( "Name", elem.Name ) );
              }
              catch( Exception ex )
              {
            data.Add( new Snoop.Data.Exception( "Name", ex ) );
              }

              data.Add( new Snoop.Data.Int( "ID", elem.Id.IntegerValue ) );
              data.Add( new Snoop.Data.String( "Unique ID", elem.UniqueId ) );
              data.Add( new Snoop.Data.Object( "Category", elem.Category ) );
              data.Add( new Snoop.Data.ElementId( "Object type", elem.GetTypeId(), elem.Document ) );
              data.Add( new Snoop.Data.Object( "Level", elem.LevelId ) );
              data.Add( new Snoop.Data.Object( "Document", elem.Document ) );
              data.Add( new Snoop.Data.Object( "Location", elem.Location ) );

              try
              {
            data.Add( new Snoop.Data.Enumerable( "Materials", elem.GetMaterialIds( false ), elem.Document ) );
              }
              catch( Exception ex )
              {
            data.Add( new Snoop.Data.Exception( "Materials", ex ) );
              }

              data.Add( new Snoop.Data.ParameterSet( "Parameters", elem, elem.Parameters ) );
              data.Add( new Snoop.Data.Enumerable( "Parameters map", elem.ParametersMap ) );
              data.Add( new Snoop.Data.Object( "Design option", elem.DesignOption ) );
              data.Add( new Snoop.Data.ElementId( "Group Id", elem.GroupId, elem.Document ) );
              data.Add( new Snoop.Data.ElementId( "Created phase", elem.CreatedPhaseId, elem.Document ) );
              data.Add( new Snoop.Data.ElementId( "Demolished phase", elem.DemolishedPhaseId, elem.Document ) );

              try
              {
            data.Add( new Snoop.Data.ElementSet( "Similar object types", elem.GetValidTypes(), elem.Document ) );
              }
              catch( Exception ex )
              {
            data.Add( new Snoop.Data.Exception( "Similar object types", ex ) );
              }

              data.Add( new Snoop.Data.Bool( "Pinned", elem.Pinned ) );
              data.Add( new Snoop.Data.ElementGeometry( "Geometry", elem, m_app.Application ) );

              data.Add( new Snoop.Data.Object( "Analytical model", elem.GetAnalyticalModel() ) );

              // Try to access the extensible storage of this element.

              foreach( Schema schema in Schema.ListSchemas() )
              {
            String objectName = "Entity with Schema [" + schema.SchemaName + "]";
            try
            {
              Entity entity = elem.GetEntity( schema );
              if( !entity.IsValid() )
            continue;
              data.Add( new Snoop.Data.Object( objectName, entity ) );
            }
            catch( System.Exception ex )
            {
              data.Add( new Snoop.Data.Exception( objectName, ex ) );
            }
              }

              // See if it is a type we are responsible for

              Area area = elem as Area;
              if( area != null )
              {
            Stream( data, area );
            return;
              }

              AreaReinforcement areaReinforcement = elem as AreaReinforcement;
              if( areaReinforcement != null )
              {
            Stream( data, areaReinforcement );
            return;
              }

              AreaReinforcementCurve areaReinforcementCurve = elem as AreaReinforcementCurve;
              if( areaReinforcementCurve != null )
              {
            Stream( data, areaReinforcementCurve );
            return;
              }

              AreaTag areaTag = elem as AreaTag;
              if( areaTag != null )
              {
            Stream( data, areaTag );
            return;
              }

              BaseArray baseArray = elem as BaseArray;
//.........这里部分代码省略.........
开发者ID:huni35,项目名称:RevitLookup,代码行数:101,代码来源:CollectorExtElement.cs

示例3: LookupAndExtractData

        /// <summary>
        /// Given an element, try to find an entity containing instance data from a given Schema Guid.
        /// </summary>
        /// <param name="storageElement">The element to query</param>
        /// <param name="schemaId">The id of the Schema to query</param>
        public static void LookupAndExtractData(Element storageElement, Guid schemaId, out SchemaWrapperTools.SchemaWrapper schemaWrapper)
        {
            Schema schemaLookup = Schema.Lookup(schemaId);
               if (schemaLookup == null)
               {
              throw new Exception("Schema not found in current document.");
               }
               schemaWrapper = SchemaWrapperTools.SchemaWrapper.FromSchema(schemaLookup);

               Entity storageElementEntityRead = storageElement.GetEntity(schemaLookup);
               if (storageElementEntityRead.SchemaGUID != schemaId)
               {
              throw new Exception("SchemaID of found entity does not match the SchemaID passed to GetEntity.");
               }

               if (storageElementEntityRead == null)
               {
              throw new Exception("Entity of given Schema not found.");
               }
        }
开发者ID:AMEE,项目名称:revit,代码行数:25,代码来源:StorageCommand.cs

示例4: EditExistingData

        /// <summary>
        /// Create a SchemaWrapper from a Schema Guid and try to find an Entity of a matching Guid
        /// in a given Element.  If successfull, try to change the data in that Entity.
        /// </summary>
        /// <param name="storageElement"></param>
        /// <param name="schemaId"></param>
        /// <param name="schemaWrapper"></param>
        public static void EditExistingData(Element storageElement, Guid schemaId, out SchemaWrapperTools.SchemaWrapper schemaWrapper)
        {
            //Try to find the schema in the active document.
               Schema schemaLookup = Schema.Lookup(schemaId);
               if (schemaLookup == null)
               {
              throw new Exception("Schema not found in current document.");
               }

               //Create a SchemaWrapper.
               schemaWrapper = SchemaWrapperTools.SchemaWrapper.FromSchema(schemaLookup);

               //Try to get an Entity of the given Schema
               Entity storageElementEntityWrite = storageElement.GetEntity(schemaLookup);
               if (storageElementEntityWrite.SchemaGUID != schemaId)
               {
              throw new Exception("SchemaID of found entity does not match the SchemaID passed to GetEntity.");
               }

               if (storageElementEntityWrite == null)
               {
              throw new Exception("Entity of given Schema not found.");
               }

               //Get the fields of the schema
               Field fieldInt0 = schemaWrapper.GetSchema().GetField(int0Name);
               Field fieldShort0 = schemaWrapper.GetSchema().GetField(short0Name);
               Field fieldDouble0 = schemaWrapper.GetSchema().GetField(double0Name);
               Field fieldFloat0 = schemaWrapper.GetSchema().GetField(float0Name);
               Field fieldBool0 = schemaWrapper.GetSchema().GetField(bool0Name);
               Field fieldString0 = schemaWrapper.GetSchema().GetField(string0Name);

               //Edit the fields.
               Transaction tStore = new Transaction(storageElement.Document, "tStore");
               tStore.Start();
               storageElementEntityWrite = null;
               storageElementEntityWrite = new Entity(schemaWrapper.GetSchema());

               storageElementEntityWrite.Set<int>(fieldInt0, 10);
               storageElementEntityWrite.Set<short>(fieldShort0, 20);
               storageElementEntityWrite.Set<double>(fieldDouble0, 14.2, DisplayUnitType.DUT_METERS);
               storageElementEntityWrite.Set<float>(fieldFloat0, 6.12f, DisplayUnitType.DUT_METERS);
               storageElementEntityWrite.Set(fieldBool0, true);
               storageElementEntityWrite.Set(fieldString0, "goodbye");
               //Set the entity back into the storage element.
               storageElement.SetEntity(storageElementEntityWrite);
               tStore.Commit();
        }
开发者ID:AMEE,项目名称:revit,代码行数:55,代码来源:StorageCommand.cs


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