如何修复块中心点问题?
C#开发|冯美娟|2018-07-19 10:00
-
回答:
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(); }