本文整理汇总了C#中FilteredElementCollector.GetEntity方法的典型用法代码示例。如果您正苦于以下问题:C# FilteredElementCollector.GetEntity方法的具体用法?C# FilteredElementCollector.GetEntity怎么用?C# FilteredElementCollector.GetEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilteredElementCollector
的用法示例。
在下文中一共展示了FilteredElementCollector.GetEntity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public static void Load(Document doc)
{
ExtensibleStorageFilter fi
= new ExtensibleStorageFilter(
ExtensibleStorage.SettingsSchema.SchemaGuid);
DataStorage dataStorage
= new FilteredElementCollector(doc)
.OfClass(typeof(DataStorage))
.WherePasses(fi)
.Where<Element>(el => Variables.defNameSettings.Equals(el.Name))
.FirstOrDefault<Element>() as DataStorage;
if (dataStorage != null)
{
Entity entity = dataStorage.GetEntity(Schema.Lookup(ExtensibleStorage.SettingsSchema.SchemaGuid));
Variables.slackOn = entity.Get<bool>("slackOn");
Variables.slackWSWarn = entity.Get<bool>("slackWSWarn");
Variables.slackModelWarn = entity.Get<bool>("slackModelWarn");
Variables.slackBPWarn = entity.Get<bool>("slackBPWarn");
Variables.slackWSInfo= entity.Get<bool>("slackWSInfo");
Variables.slackModelInfo = entity.Get<bool>("slackModelInfo");
Variables.slackBPInfo = entity.Get<bool>("slackBPInfo");
Variables.slackExtraTrackPin = entity.Get<bool>("slackExtraTrackPin");
Variables.slackCh = entity.Get<string>("slackCh");
Variables.slackChId = entity.Get<string>("slackChId");
Variables.giphySet = entity.Get<int>("giphySet");
Variables.tidySet = entity.Get<int>("tidySet");
Variables.slackToken = entity.Get<string>("slackToken");
}
else
{
Variables.slackCh = null;
Variables.slackChId = null;
Variables.slackOn = false;
Variables.slackToken = null;
}
}
示例2: 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();
}
示例3: 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;
}