www.mxdraw.com
内容索引主面
前一个向上下一个
IMxDrawLayerTable 接口

控件中的层表类型

IDL
[ object, uuid(62BD4338-5C10-43B4-AD46-8BBBA0E2AC72), dual, nonextensible, helpstring("IMxDrawLayerTable interface"), pointer_default(unique) ]
interface IMxDrawLayerTable : IMxDrawSymbolTable;

MxDrawLayerTable.idl

例如:C#代码,创建一个图层,并把该图层设置成当前图层的例程。

    private void CreateLayer()
    {
        // sNewLayerName新创建的图层名
        string sNewLayerName = "TestNewLayer";
        MxDrawApplication app = new MxDrawApplication();

        // 得到当前数据为的层表对象
        MxDrawLayerTable layerTable = app.WorkingDatabase().GetLayerTable();

        // 向层表中新增一个层表记录

        MxDrawLayerTableRecord layerTableRec = layerTable.Add(sNewLayerName);

        // 设置新图层的颜色。

        MxDrawMcCmColor color = new MxDrawMcCmColor();
        color.SetRGB(255, 0, 0);
        layerTableRec.Color = color;

        // 把新建的层设置成当前层
        app.WorkingDatabase().CurrentlyLayerName = sNewLayerName;
    }

例如:隐藏选择实体的图层

        else if(e.iCommandId == 14)
        {
            // 隐藏选择实体的层。

            MxDrawUtility mxUtility = new MxDrawUtility();

            object getPt;
            MxDrawEntity ent = mxUtility.GetEntity(out getPt, "n 选择要关闭图层的实体:");
            if (ent == null)
            {
                return;
            }
            string sLayerName = ent.Layer;
            MxDrawDatabase database = (MxDrawDatabase)axMxDrawX1.GetDatabase();

            MxDrawLayerTable layerTable = database.GetLayerTable();

            MxDrawLayerTableRecord layerTableRec = layerTable.GetAt(sLayerName, false);
            if(layerTable != null)
            {
                layerTableRec.IsOff = true;
            }
        }

例如:打开所图层代码

           MxDrawDatabase database = (MxDrawDatabase)axMxDrawX1.GetDatabase();

         MxDrawLayerTable layerTable = database.GetLayerTable();
         MxDrawLayerTableIterator iter = layerTable.NewIterator();
         if (iter == null)
             return;

         for(;!iter.Done();iter.Step(true,false) )
         {
             MxDrawLayerTableRecord layerTableRec = iter.GetRecord();
             layerTableRec.IsOff = false;
         }

例如: VC++ COM 得到图层名.

        void CTestVc2005Dlg::GetAllLayerName(std::vector<CString>& vecLayer)
        {
            IDispatchPtr spDispatch(m_ocx.GetDatabase(),false);
            IMxDrawDatabasePtr spDatabase;
            spDispatch->QueryInterface(&spDatabase);

            IMxDrawLayerTablePtr layerTable = spDatabase->GetLayerTable();
            IMxDrawLayerTableIteratorPtr iter = layerTable->NewIterator();
            if (iter == NULL)
                return;

            for(;!iter->Done();iter->Step(VARIANT_TRUE,VARIANT_TRUE) )
            {
                IMxDrawLayerTableRecordPtr layerTableRec = iter->GetRecord();
                _bstr_t bsName = layerTableRec->GetName();

                CString sName;
                sName = bsName.GetBSTR();

                vecLayer.push_back(sName);
            }
        }

 

例如: 锁定所有图层C#

            MxDrawDatabase database = (MxDrawDatabase)axMxDrawX1.GetDatabase();
            MxDrawLayerTable layerTable = database.GetLayerTable();
            MxDrawLayerTableIterator iter = layerTable.NewIterator();
            for (; !iter.Done(); iter.Step())
            {
                MxDrawLayerTableRecord layerRec = iter.GetRecord();
                layerRec.IsLocked = true;
            }
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!