- 积分
- 25214
- 明经币
- 个
- 注册时间
- 2003-6-27
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2018-12-18 09:48:59
|
显示全部楼层
/// <summary>
/// 以DBX方式插入dwg文件里面的一个图块
/// </summary>
/// <param name="fileName"></param>
/// <param name="blockName"></param>
/// <returns></returns>
static public bool InsertBlock_DBX(string fileName, string blockName)
{
//ae.WriteMessage("DBX_InsertBlock start " );
AxDbDocument dbx = new AxDbDocument();
try
{
dbx.Open(fileName, "");
AcadBlock[] blk1 = new AcadBlock[1];
for (int i = 0; i < dbx.Blocks.Count; i++)
{
if (dbx.Blocks.Item(i).Name == blockName)
{
blk1[0] = (AcadBlock)dbx.Blocks.Item(i);
Object missing = Type.Missing;
dbx.CopyObjects(blk1, csp.CurSpace, ref missing);
an.OutSideInsert(blockName, null, true);
System.Runtime.InteropServices.Marshal.ReleaseComObject(dbx);
return true;
}
}
ae.WriteMessage("\nCann't find block : " + blockName, 1);
return false;
}
catch (System.Exception ex)
{
ae.WriteMessage(ex);
System.Runtime.InteropServices.Marshal.ReleaseComObject(dbx);
return false;
}
} |
|