插入图块,怎么设置左下角为基点?
MxDraw网页开发|黄洪辉|2018-05-07 16:49
-
回答:
// 插入块的块名。 var sBlkName = "junxing"; // 把要插入的块文件引入到控件数据库中。 var sBlkFile = mxOcx.GetOcxAppPath() + "\\Blk\\attribblock.dwg"; mxOcx.InsertBlock(sBlkFile, sBlkName); var database = mxOcx.GetDatabase(); var blkTab = database.GetBlockTable(); var rec = blkTab.GetAt("junxing"); if (rec == null) return; var iter = rec.NewIterator(); var dMinX = 0, dMinY = 0; var isSet = false; for (; !iter.Done(); iter.Step()) { var ent = iter.GetEntity(); var pt1 =mxOcx.NewPoint(); var pt2 =mxOcx.NewPoint(); ent.GetBoundingBox(pt1,pt2); if (pt1 == null) continue; if (isSet) { if (dMinX > pt1.x) dMinX = pt1.x; if (dMinY > pt1.y) dMinY = pt1.y; } else { dMinX = pt1.x; dMinY = pt1.y; isSet = true; } } if (isSet) { var pt =mxOcx.NewPoint(); pt.x = dMinX; pt.y = dMinY; rec.Origin = pt; } mxOcx.DrawBlockReference(0, 0, "junxing", 1, 0); mxOcx.ZoomAll();