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

块表记录类型接口,所有可见实体都会放到块表记录中用于显示 支持扩展属性"isFromExternalReference",类型为: LONG 支持扩展属性"pathName",类型为: CString 支持扩展属性函数"AddCustomEntity",添一个自定义实体

IDL
[ object, uuid(0898BDA3-7A39-4B5B-8CCB-AAD485AB0893), dual, nonextensible, helpstring("IMxDrawBlockTableRecord interface"), pointer_default(unique) ]
interface IMxDrawBlockTableRecord : IMxDrawSymbolTableRecord;

MxDrawBlockTableRecord.idl

例如: 让用户在图上,选择一个图块,把它替换成,Rect.dwg,C#代码.

            MxDrawUtility mxUtility = new MxDrawUtility();

            object getPt;
            MxDrawEntity ent = mxUtility.GetEntity(out getPt, "n 选择块引用实体:");
            if (ent == null)
            {
                return;
            }

            if (ent is MxDrawBlockReference)
            {
                MxDrawBlockReference blkRef = (MxDrawBlockReference)ent;

                String sBlkFilePath = axMxDrawX1.GetOcxAppPath() + "\Blk\Rect.dwg";
                axMxDrawX1.InsertBlock(sBlkFilePath, "MyBlk2");

                MxDrawDatabase curDatabase = (MxDrawDatabase)(axMxDrawX1.GetDatabase());
                MxDrawBlockTable blkTable = curDatabase.GetBlockTable();

                MxDrawBlockTableRecord myblkRec =  blkTable.GetAt("MyBlk2", false);
                if(myblkRec == null)
                {
                    return;
                }

                blkRef.BlockTableRecordId = myblkRec.ObjectID;

            }

 

例如: 在块表记录中添加一个自定义实体.

        MxDrawDatabase database = (MxDrawDatabase)axMxDrawX1.GetDatabase();
        MxDrawBlockTableRecord blkRec = database.CurrentSpace();

        // 调用AddCustomEntity函数绘制自定义实体。 逗号后的字符串"DrawCustEntity"是自定义实体的GUID
        MxDrawResbuf ret =  blkRec.GetProp("AddCustomEntity,DrawCustEntity");

        // 得到自定义实体。
        MxDrawCustomEntity ent = (MxDrawCustomEntity)database.ObjectIdToObject(ret.AtObjectId(0));


        // 设置自定义实体的属性。
        ent.BeginSetValue();
        ent.SetDouble("Width", 30);

        MxDrawPoint pt1 = new MxDrawPoint();
        pt1.x = 10;
        pt1.y = 10;
        MxDrawPoint pt2 = new MxDrawPoint();

        pt2.x = 20;
        pt2.y = 20;
        ent.SetPoint("Point1", pt1);
        ent.SetPoint("Point2", pt2);

        ent.SetLong("Count", 2);
        ent.EntSetValue();
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!