1、主要用到函数说明:IMxDrawEntity::GetBoundingBox
2、返回实体的最小矩形框外包。详细说明如下:
参数 | 说明 |
[out] IMxDrawPoint** minPoint | 外包框的左下角点 |
[out] IMxDrawPoint** maxPoint | 外包框的右上角点 |
3、c#中实现代码说明:
MxDrawDatabase databae = (MxDrawDatabase)axMxDrawX1.GetDatabase();
MxDrawBlockTable blkTab = databae.GetBlockTable();
MxDrawBlockTableIterator mBlockTableiter = blkTab.NewIterator();
for (; !mBlockTableiter.Done(); mBlockTableiter.Step())
{
MxDrawBlockTableRecord blkRec = mBlockTableiter.GetRecord();
MxDrawBlockTableRecordIterator mBlockTableReciter = blkRec.NewIterator();
MxDrawPoint mMaxPt = new MxDrawPoint();
MxDrawPoint mMinPt = new MxDrawPoint();
MxDrawPoint mMaxPtTemp = new MxDrawPoint();
MxDrawPoint mMinPtTemp = new MxDrawPoint();
for (; !mBlockTableReciter.Done(); mBlockTableReciter.Step(true, false))
{
MxDrawEntity ent = mBlockTableReciter.GetEntity();
ent.GetBoundingBox(out mMinPtTemp, out mMaxPtTemp);
if ((mMinPtTemp == null) || (mMaxPtTemp == null))
break;
mMaxPt.x = Math.Max(mMaxPt.x, mMaxPtTemp.x);
mMaxPt.y = Math.Max(mMaxPt.y, mMaxPtTemp.y);
mMinPt.x = Math.Min(mMinPt.x, mMinPtTemp.x);
mMinPt.y = Math.Min(mMinPt.y, mMinPtTemp.y);
}
if ((mMinPtTemp == null) || (mMaxPtTemp == null))
continue;
MxDrawPoint mNewBasePt = new MxDrawPoint();
mNewBasePt.x = mMinPt.x + (mMaxPt.x - mMinPt.x) / 2;
mNewBasePt.y = mMinPt.y + (mMaxPt.y - mMinPt.y) / 2;
blkRec.Origin = mNewBasePt;
axMxDrawX1.Regen();
}