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


C# FilteredElementCollector.SetEntity方法代码示例

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


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

示例1: Set

        public static void Set(Application app, Document doc, string name, SlackSettings s)
        {
            ExtensibleStorageFilter f
                = new ExtensibleStorageFilter(
                    ExtensibleStorage.SettingsSchema.SchemaGuid);

            DataStorage dataStorage
                = new FilteredElementCollector(doc)
                .OfClass(typeof(DataStorage))
                .WherePasses(f)
                .Where<Element>(e => name.Equals(e.Name))
                .FirstOrDefault<Element>() as DataStorage;

            Entity entity;
            if (dataStorage == null)
            {
                using (Transaction t = new Transaction(doc, "Create settings schema"))
                {
                    t.Start();

                    dataStorage = DataStorage.Create(doc);
                    dataStorage.Name = name;

                    entity = new Entity(ExtensibleStorage.SettingsSchema.InitializeSchema());
                    dataStorage.SetEntity(entity);

                    t.Commit();
                }
            }

            Transaction updateSettings = new Transaction(doc, "Update settings");
            updateSettings.Start();
            entity = dataStorage.GetEntity(ExtensibleStorage.SettingsSchema.InitializeSchema());

            entity.Set("slackOn", s.slackOn);
            entity.Set("slackWSWarn", s.slackWSWarn);
            entity.Set("slackModelWarn", s.slackModelWarn);
            entity.Set("slackBPWarn", s.slackBPWarn);
            entity.Set("slackWSInfo", s.slackWSInfo);
            entity.Set("slackModelInfo", s.slackModelInfo);
            entity.Set("slackBPInfo", s.slackBPInfo);
            entity.Set("slackExtraTrackPin", s.slackExtraTrackPin);
            entity.Set("giphySet", s.giphySet);
            entity.Set("tidySet", s.tidySet);
            entity.Set("slackToken", s.slackToken);
            entity.Set("slackCh", s.slackCh);
            entity.Set("slackChId", s.slackChId);

            dataStorage.SetEntity(entity);
            updateSettings.Commit();
        }
开发者ID:pix3lot,项目名称:Slackit,代码行数:51,代码来源:ExtensibleStorage.cs

示例2: Get

        /// <summary>
        /// Retrieve an existing named Guid 
        /// in the specified Revit document or
        /// optionally create and return a new
        /// one if it does not yet exist.
        /// </summary>
        public static bool Get(
            Document doc,
            string name,
            out Guid guid,
            bool create = true)
        {
            bool rc = false;

              guid = Guid.Empty;

              // Retrieve a DataStorage element with our
              // extensible storage entity attached to it
              // and the specified element name. Only zero
              // or one should exist.

              ExtensibleStorageFilter f
            = new ExtensibleStorageFilter(
              JtNamedGuidStorageSchema.SchemaGuid );

              DataStorage dataStorage
            = new FilteredElementCollector( doc )
              .OfClass( typeof( DataStorage ) )
              .WherePasses( f )
              .Where<Element>( e => name.Equals( e.Name ) )
              .FirstOrDefault<Element>() as DataStorage;

              if( dataStorage == null )
              {
            if( create )
            {
              using( Transaction t = new Transaction(
            doc, "Create named Guid storage" ) )
              {
            t.Start();

            // Create named data storage element

            dataStorage = DataStorage.Create( doc );
            dataStorage.Name = name;

            // Create entity to store the Guid data

            Entity entity = new Entity(
              JtNamedGuidStorageSchema.GetSchema() );

            entity.Set( "Guid", guid = Guid.NewGuid() );

            // Set entity to the data storage element

            dataStorage.SetEntity( entity );

            t.Commit();

            rc = true;
              }
            }
              }
              else
              {
            // Retrieve entity from the data storage element.

            Entity entity = dataStorage.GetEntity(
              JtNamedGuidStorageSchema.GetSchema( false ) );

            Debug.Assert( entity.IsValid(),
              "expected a valid extensible storage entity" );

            if( entity.IsValid() )
            {
              guid = entity.Get<Guid>( "Guid" );

              rc = true;
            }
              }
              return rc;
        }
开发者ID:jeremytammik,项目名称:the_building_coder_samples,代码行数:82,代码来源:JtNamedGuidStorage.cs


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