public static DictionaryProperty CreateZoneIndex(Grid grid)
        {
            List<Slb.Ocean.Petrel.DomainObject.PillarGrid.Zone> ListOfZones = KandaPropertyCreator.GetAllLowLevelZones(grid.Zones);
            PropertyCollection pc = grid.PropertyCollection;
            Index3 CellIndex = new Index3();

             using (ITransaction trans = DataManager.NewTransaction())
             {
                 trans.Lock(pc);

                 DictionaryTemplate TemplateOfProperty = PetrelProject.WellKnownTemplates.FaciesGroup.ZonesMain;
                 DictionaryProperty ZoneIndex = pc.CreateDictionaryProperty(TemplateOfProperty);
                 ZoneIndex.Name = "Zone Index";
                 ColorTableRoot Root = ColorTableRoot.Get(PetrelProject.PrimaryProject);
                 DictionaryColorTableAccess TableAccess = Root.GetDictionaryColorTableAccess(ZoneIndex);
                 Slb.Ocean.Petrel.DomainObject.ColorTables.DictionaryColorTableEntry ColorTableEntry = new Slb.Ocean.Petrel.DomainObject.ColorTables.DictionaryColorTableEntry();

                 int max_i = grid.NumCellsIJK.I;
                 int max_j = grid.NumCellsIJK.J;
                 int max_k = grid.NumCellsIJK.K;
                 int begin; int end;

                 int code = 0;

                 foreach(Slb.Ocean.Petrel.DomainObject.PillarGrid.Zone zone in ListOfZones)
                 {
                     // code = ZoneIndex.AddFaciesCode(zone.Name);
                     ColorTableEntry.CodeValue = code;
                     ColorTableEntry.Name = zone.Name;
                        using (ITransaction trans2 = DataManager.NewTransaction())
                       {
                           trans2.Lock(TableAccess);

                           TableAccess.InsertEntry(ColorTableEntry);

                           trans2.Commit();
                       }

                        if (zone.BaseK > zone.TopK) { begin = zone.TopK; end = zone.BaseK; }
                        else { begin = zone.BaseK; end = zone.TopK; }

                       for (int k = begin; k <= end; k++)
                       {

                           for (int i = 0; i < max_i; i++)
                           {
                               for (int j = 0; j < max_j; j++)
                               {   CellIndex.I = i; CellIndex.J = j;  CellIndex.K = k;

                                   if(grid.IsCellDefined(CellIndex))
                                   {

                                       ZoneIndex[CellIndex] = code;
                                   }
                               }
                           }
                       }
                       code = code + 1;
                 }

                 trans.Commit();
                 return ZoneIndex;
             }
        }