本文整理汇总了C#中SchemaBuilder.SetWriteAccessLevel方法的典型用法代码示例。如果您正苦于以下问题:C# SchemaBuilder.SetWriteAccessLevel方法的具体用法?C# SchemaBuilder.SetWriteAccessLevel怎么用?C# SchemaBuilder.SetWriteAccessLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SchemaBuilder
的用法示例。
在下文中一共展示了SchemaBuilder.SetWriteAccessLevel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIDocument uiDoc = commandData.Application.ActiveUIDocument;
Document doc = uiDoc.Document;
// Create transaction for working with schema
Transaction trans = new Transaction(doc, "Extensible Storage");
trans.Start();
// Select a wall element
Wall wall = null;
try
{
Reference r = uiDoc.Selection.PickObject(ObjectType.Element,
new WallSelectionFilter());
wall = doc.GetElement(r) as Wall;
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
message = "Nothing selected; please select a wall to attach extensible data to.";
return Result.Failed;
}
Debug.Assert(null != wall, "expected a wall to be selected");
if (null == wall)
{
message = "Please select a wall to attach extensible data to.";
return Result.Failed;
}
// Create a schema builder
SchemaBuilder builder = new SchemaBuilder(_guid);
// Set read and write access levels
builder.SetReadAccessLevel(AccessLevel.Public);
builder.SetWriteAccessLevel(AccessLevel.Public);
// Note: if this was set as vendor or application access,
// we would have been additionally required to use SetVendorId
// Set name to this schema builder
builder.SetSchemaName("WallSocketLocation");
builder.SetDocumentation("Data store for socket related info in a wall");
// Create field1
FieldBuilder fieldBuilder1 =
builder.AddSimpleField("SocketLocation", typeof(XYZ));
// Set unit type
fieldBuilder1.SetUnitType(UnitType.UT_Length);
// Add documentation (optional)
// Create field2
FieldBuilder fieldBuilder2 =
builder.AddSimpleField("SocketNumber", typeof(string));
//fieldBuilder2.SetUnitType(UnitType.UT_Custom);
// Register the schema object
Schema schema = builder.Finish();
// Create an entity (object) for this schema (class)
Entity ent = new Entity(schema);
Field socketLocation = schema.GetField("SocketLocation");
ent.Set<XYZ>(socketLocation, new XYZ(2, 0, 0), DisplayUnitType.DUT_METERS);
Field socketNumber = schema.GetField("SocketNumber");
ent.Set<string>(socketNumber, "200");
wall.SetEntity(ent);
// Now create another entity (object) for this schema (class)
Entity ent2 = new Entity(schema);
Field socketNumber1 = schema.GetField("SocketNumber");
ent2.Set<String>(socketNumber1, "400");
wall.SetEntity(ent2);
// Note: this will replace the previous entity on the wall
// List all schemas in the document
string s = string.Empty;
//.........这里部分代码省略.........
示例2: ModifyObjects
private void ModifyObjects(List<RevitObject> existingObjects, List<ElementId> existingElems, Document doc, Guid uniqueId, bool profileWarning, string nickName, int runId)
{
// Create new Revit objects.
//List<LyrebirdId> newUniqueIds = new List<LyrebirdId>();
// Determine what kind of object we're creating.
RevitObject ro = existingObjects[0];
#region Normal Origin based FamilyInstance
// Modify origin based family instances
if (ro.Origin != null)
{
// Find the FamilySymbol
FamilySymbol symbol = FindFamilySymbol(ro.FamilyName, ro.TypeName, doc);
LevelType lt = FindLevelType(ro.TypeName, doc);
GridType gt = FindGridType(ro.TypeName, doc);
if (symbol != null || lt != null)
{
// Get the hosting ID from the family.
Family fam = null;
Parameter hostParam = null;
int hostBehavior = 0;
try
{
fam = symbol.Family;
hostParam = fam.get_Parameter(BuiltInParameter.FAMILY_HOSTING_BEHAVIOR);
hostBehavior = hostParam.AsInteger();
}
catch{}
//FamilyInstance existingInstance = doc.GetElement(existingElems[0]) as FamilyInstance;
using (Transaction t = new Transaction(doc, "Lyrebird Modify Objects"))
{
t.Start();
try
{
Schema instanceSchema = null;
try
{
instanceSchema = Schema.Lookup(instanceSchemaGUID);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
if (instanceSchema == null)
{
SchemaBuilder sb = new SchemaBuilder(instanceSchemaGUID);
sb.SetWriteAccessLevel(AccessLevel.Vendor);
sb.SetReadAccessLevel(AccessLevel.Public);
sb.SetVendorId("LMNA");
// Create the field to store the data in the family
FieldBuilder guidFB = sb.AddSimpleField("InstanceID", typeof(string));
guidFB.SetDocumentation("Component instance GUID from Grasshopper");
// Create a filed to store the run number
FieldBuilder runIDFB = sb.AddSimpleField("RunID", typeof(int));
runIDFB.SetDocumentation("RunID for when multiple runs are created from the same data");
// Create a field to store the GH component nickname.
FieldBuilder nickNameFB = sb.AddSimpleField("NickName", typeof(string));
nickNameFB.SetDocumentation("Component NickName from Grasshopper");
sb.SetSchemaName("LMNAInstanceGUID");
instanceSchema = sb.Finish();
}
FamilyInstance fi = null;
XYZ origin = XYZ.Zero;
if (lt != null)
{
for (int i = 0; i < existingObjects.Count; i++)
{
RevitObject obj = existingObjects[i];
Level lvl = doc.GetElement(existingElems[i]) as Level;
if (lvl.ProjectElevation != (UnitUtils.ConvertToInternalUnits(obj.Origin.Z, lengthDUT)))
{
double offset = lvl.Elevation - lvl.ProjectElevation;
lvl.Elevation = (UnitUtils.ConvertToInternalUnits(obj.Origin.Z + offset, lengthDUT));
}
SetParameters(lvl, obj.Parameters, doc);
}
}
else if (hostBehavior == 0)
{
for (int i = 0; i < existingObjects.Count; i++)
{
RevitObject obj = existingObjects[i];
fi = doc.GetElement(existingElems[i]) as FamilyInstance;
// Change the family and symbol if necessary
//.........这里部分代码省略.........
示例3: GetStorageSchema
private Schema GetStorageSchema()
{
var bld = new SchemaBuilder(_schemaGuid);
bld.SetSchemaName("BimLibraryData");
bld.SetWriteAccessLevel(AccessLevel.Public);
bld.SetReadAccessLevel(AccessLevel.Public);
//bld.SetVendorId("ADSK");
bld.SetDocumentation("This schema stores project specific application data of Czech BIM Library.");
bld.AddSimpleField(FieldNameData, typeof(String)).SetDocumentation("Data field");
return bld.Finish();
}
示例4: CreateObjects
private void CreateObjects(List<RevitObject> revitObjects, Document doc, Guid uniqueId, int runId, string nickName)
{
// Create new Revit objects.
//List<LyrebirdId> newUniqueIds = new List<LyrebirdId>();
// Get the levels from the project
FilteredElementCollector lvlCollector = new FilteredElementCollector(doc);
lvlCollector.OfClass(typeof(Level)).ToElements().OfType<Level>();
// Determine what kind of object we're creating.
RevitObject ro = revitObjects[0];
#region Normal Origin based Family Instance
if (ro.Origin != null)
{
// Find the FamilySymbol
FamilySymbol symbol = FindFamilySymbol(ro.FamilyName, ro.TypeName, doc);
LevelType lt = FindLevelType(ro.TypeName, doc);
if (symbol != null || lt != null)
{
// Get the hosting ID from the family.
Family fam = null;
Parameter hostParam = null;
int hostBehavior = 0;
try
{
fam = symbol.Family;
hostParam = fam.get_Parameter(BuiltInParameter.FAMILY_HOSTING_BEHAVIOR);
hostBehavior = hostParam.AsInteger();
}
catch{}
using (Transaction t = new Transaction(doc, "Lyrebird Create Objects"))
{
t.Start();
try
{
// Create the Schema for the instances to store the GH Component InstanceGUID and the path
Schema instanceSchema = null;
try
{
instanceSchema = Schema.Lookup(instanceSchemaGUID);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
if (instanceSchema == null)
{
SchemaBuilder sb = new SchemaBuilder(instanceSchemaGUID);
sb.SetWriteAccessLevel(AccessLevel.Vendor);
sb.SetReadAccessLevel(AccessLevel.Public);
sb.SetVendorId("LMNA");
// Create the field to store the data in the family
FieldBuilder guidFB = sb.AddSimpleField("InstanceID", typeof(string));
guidFB.SetDocumentation("Component instance GUID from Grasshopper");
// Create a filed to store the run number
FieldBuilder runIDFB = sb.AddSimpleField("RunID", typeof(int));
runIDFB.SetDocumentation("RunID for when multiple runs are created from the same data");
// Create a field to store the GH component nickname.
FieldBuilder nickNameFB = sb.AddSimpleField("NickName", typeof(string));
nickNameFB.SetDocumentation("Component NickName from Grasshopper");
sb.SetSchemaName("LMNAInstanceGUID");
instanceSchema = sb.Finish();
}
FamilyInstance fi = null;
XYZ origin = XYZ.Zero;
if (lt != null)
{
// Create a level for the object.
foreach (RevitObject obj in revitObjects)
{
try
{
Level lvl = doc.Create.NewLevel(UnitUtils.ConvertToInternalUnits(obj.Origin.Z, lengthDUT));
lvl.LevelType = lt;
// Set the parameters.
SetParameters(lvl, obj.Parameters, doc);
// Assign the GH InstanceGuid
AssignGuid(lvl, uniqueId, instanceSchema, runId, nickName);
}
catch { }
}
}
else if (hostBehavior == 0)
{
int x = 0;
foreach (RevitObject obj in revitObjects)
{
try
{
List<LyrebirdPoint> originPts = new List<LyrebirdPoint>();
Level lvl = GetLevel(originPts, doc);
//.........这里部分代码省略.........
示例5: InitializeSchema
/// <summary>
/// Retrieve our extensible storage schema
/// or optionally create a new one if it does
/// not yet exist.
/// </summary>
public static Schema InitializeSchema(
bool create = true)
{
Schema schema = Schema.Lookup(SchemaGuid);
if (create && null == schema)
{
SchemaBuilder schemaBuilder =
new SchemaBuilder(SchemaGuid);
schemaBuilder.SetSchemaName(
"SlackitSettings");
schemaBuilder.SetReadAccessLevel(AccessLevel.Public);
schemaBuilder.SetWriteAccessLevel(AccessLevel.Public);
schemaBuilder.AddSimpleField(
"slackOn", typeof(Boolean));
schemaBuilder.AddSimpleField(
"slackWSWarn", typeof(Boolean));
schemaBuilder.AddSimpleField(
"slackModelWarn", typeof(Boolean));
schemaBuilder.AddSimpleField(
"slackBPWarn", typeof(Boolean));
schemaBuilder.AddSimpleField(
"slackWSInfo", typeof(Boolean));
schemaBuilder.AddSimpleField(
"slackModelInfo", typeof(Boolean));
schemaBuilder.AddSimpleField(
"slackBPInfo", typeof(Boolean));
schemaBuilder.AddSimpleField(
"slackExtraTrackPin", typeof(Boolean));
schemaBuilder.AddSimpleField(
"giphySet", typeof(int));
schemaBuilder.AddSimpleField(
"tidySet", typeof(int));
schemaBuilder.AddSimpleField(
"slackToken", typeof(String));
schemaBuilder.AddSimpleField(
"slackCh", typeof(String));
schemaBuilder.AddSimpleField(
"slackChId", typeof(String));
schema = schemaBuilder.Finish();
}
return schema;
}