图纸插入外部dwg图块的问题
请教各位,如何将外部定义好的dwg图块文件调入到当前文件中? 截取我的trans类的函数,如果想单独使用,要改写下public bool GetBlockDefFromFile(string filename, string blkdefname, bool over)
{
try
{
bool has = BlockTable.GetRecorId(blkdefname) != ObjectId.Null;
if ((has && over) || !has)
{
using (DBTransaction t = new DBTransaction(filename))
{
ObjectId id = t.BlockTable.GetRecorId(blkdefname);
BlockTableRecord btr = t.GetObject<BlockTableRecord>(id);
if (!btr.IsAnonymous && !btr.IsLayout)
{
t.Database.WblockCloneObjects
(
new ObjectIdCollection { id },
Database.BlockTableId,
new IdMapping(),
DuplicateRecordCloning.Replace,
false
);
}
}
}
return true;
}
catch
{ }
return false;
}
public bool GetBlockDefFromFile(string filename, bool over)
{
try
{
FileInfo fi = new FileInfo(filename);
string blkdefname = fi.Name;
if (blkdefname.Contains("."))
{
blkdefname = blkdefname.Substring(0, blkdefname.LastIndexOf('.'));
}
bool has = BlockTable.GetRecorId(blkdefname) != ObjectId.Null;
if ((has && over) || !has)
{
Database db = new Database();
db.ReadDwgFile(filename, FileShare.Read, true, null);
Database.Insert(BlockTableRecord.ModelSpace, blkdefname, db, false);
}
return true;
}
catch
{ }
return false;
}
<p>可以实现,谢谢了!</p>
<p> </p> 好东西,东西好
页:
[1]