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


C# SchemaBuilder.SetReadAccessLevel方法代码示例

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


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

示例1: CreateSchemeAndStoreData

        // Create a data structure, attach it to a wall, populate it with data, and retrieve the data back from the wall
        public void CreateSchemeAndStoreData(FamilySymbol titleblock)
        {
            SchemaBuilder schemaBuilder = new SchemaBuilder(new Guid("1a68d420-96dd-44aa-a1de-000774a6104b"));
            schemaBuilder.SetReadAccessLevel(AccessLevel.Public); // allow anyone to read the object
            schemaBuilder.SetSchemaName("TitleBlockSettings");

            // create a field to store data
            FieldBuilder fieldBuilder_titleblockName = schemaBuilder.AddSimpleField("titleblockName", typeof(string));

            FieldBuilder fieldBuilder_cellSizeDistance_X = schemaBuilder.AddSimpleField("cellSizeDistance_X", typeof(string));
            //fieldBuilder_cellSizeDistance_X.SetUnitType(UnitType.UT_Length);
            FieldBuilder fieldBuilder_lowerGap_X = schemaBuilder.AddSimpleField("lowerGap_X", typeof(string));
            //fieldBuilder_lowerGap_X.SetUnitType(UnitType.UT_Length);
            FieldBuilder fieldBuilder_additionalEdge_X = schemaBuilder.AddSimpleField("additionalEdge_X", typeof(string));
            //fieldBuilder_additionalEdge_X.SetUnitType(UnitType.UT_Length);
            FieldBuilder fieldBuilder_fineTune_X = schemaBuilder.AddSimpleField("fineTune_X", typeof(string));
            //fieldBuilder_fineTune_X.SetUnitType(UnitType.UT_Length);

            FieldBuilder fieldBuilder_cellSizeDistance_Y = schemaBuilder.AddSimpleField("cellSizeDistance_Y", typeof(string));
            //fieldBuilder_cellSizeDistance_Y.SetUnitType(UnitType.UT_Length);
            FieldBuilder fieldBuilder_lowerGap_Y = schemaBuilder.AddSimpleField("lowerGap_Y", typeof(string));
            //fieldBuilder_lowerGap_Y.SetUnitType(UnitType.UT_Length);
            FieldBuilder fieldBuilder_additionalEdge_Y = schemaBuilder.AddSimpleField("additionalEdge_Y", typeof(string));
            //fieldBuilder_additionalEdge_Y.SetUnitType(UnitType.UT_Length);
            FieldBuilder fieldBuilder_fineTune_Y = schemaBuilder.AddSimpleField("fineTune_Y", typeof(string));
            //fieldBuilder_fineTune_Y.SetUnitType(UnitType.UT_Length);

            FieldBuilder fieldBuilder_cellGrid_Length = schemaBuilder.AddSimpleField("cellGrid_Length", typeof(string));
            FieldBuilder fieldBuilder_cellGrid_Height = schemaBuilder.AddSimpleField("cellGrid_Height", typeof(string));

            //fieldBuilder.SetDocumentation("store length of cell size in X direction.");

            Schema schema = schemaBuilder.Finish(); // register the Schema object
        }
开发者ID:dannysbentley,项目名称:alignviewtosheetcell,代码行数:35,代码来源:SchemaAndStoreData.cs

示例2: 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;
//.........这里部分代码省略.........
开发者ID:vnoves,项目名称:RevitTrainingMaterial,代码行数:101,代码来源:6_ExtensibleStorage.cs

示例3: 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
//.........这里部分代码省略.........
开发者ID:samuto,项目名称:Lyrebird,代码行数:101,代码来源:LyrebirdService.cs

示例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);
//.........这里部分代码省略.........
开发者ID:samuto,项目名称:Lyrebird,代码行数:101,代码来源:LyrebirdService.cs

示例5: 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();
        }
开发者ID:martin1cerny,项目名称:BIM-Library-CZ-Revit,代码行数:12,代码来源:ProjectSettingsManager.cs

示例6: 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;
            }
开发者ID:pix3lot,项目名称:Slackit,代码行数:65,代码来源:ExtensibleStorage.cs


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