C#+ArcGIS修改图层名称和别名

据帮助文档

        Object classes in a Geodatabase can have between one and three names. The name of the object class, which is the same as the name of the table in the DBMS in which the objects in the object class are stored, the alias name which the user can set for display purposes in end user applications. The third name is the model name which is a tool for developers of custom objects to use to guarantee the names of objects independent of the true name or alias name.

代码:以gdb中图层为例修改图层名称(name)和别名(alias name)

public void AlterName()
{
    Type type = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
    IWorkspaceFactory pWorksapcFactory = (IWorkspaceFactory)Activator.CreateInstance(type);
    IWorkspace pWorkspace = pWorksapcFactory.OpenFromFile(@"F:\GIS测试数据\测试.gdb", 0);

    IFeatureWorkspace pFWK = pWorkspace as IFeatureWorkspace;
    IFeatureClass pFeatureClass = pFWK.OpenFeatureClass("SSS");

    //修改图层名称
    IDataset dataset = pFeatureClass as IDataset;
    dataset.Rename("MC");
    //修改图层别名
    AlterAliasName(pFeatureClass);
}

/// <summary>
/// 修改数据集别名
/// </summary>
/// <param name="objectClass">对象类</param>
public void AlterAliasName(IObjectClass objectClass)
{
    //cast for the IClassSchemaEdit
    IClassSchemaEdit pOcSchemaEdit = objectClass as IClassSchemaEdit;

    //set and exclusive lock on the class 设置并独占锁
    ISchemaLock schemaLock = (ISchemaLock)objectClass;
    schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);

    //alter the class extension for the class
    pOcSchemaEdit.AlterAliasName("修改别名");

    //release the exclusive lock 释放锁
    schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值