CAD插入图块,左下角设置成插入基点(网页版)
js代码如下:// 插入块的块名。
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())
{
varent = 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();
页:
[1]