在c#下插入块
www.dimcax.com
在c#下插入块 public class testinsert
{
[commandmethod("testinsert")]
static public void doit()
{
document doc = application.documentmanager.mdiactivedocument;
editor ed = doc.editor;
promptresult res = ed.getstring("give me a file to insert");
if (res.status != promptstatus.ok)
return;
string fname = res.stringresult;
if (!file.exists(fname))
fname = hostapplicationservices.current.findfile(fname, doc.database, findfilehint.default);
using (database db = new database(false, false))
{
//read drawing
db.readdwgfile(fname, fileshare.read, true, null);
using (transaction t = doc.transactionmanager.starttransaction())
{
//insert it as a new block
objectid idbtr = doc.database.insert("test", db, false);
//create a ref to the block
blocktable bt = (blocktable)t.getobject(doc.database.blocktableid, openmode.forread);
blocktablerecord btr = (blocktablerecord)t.getobject(bt[blocktablerecord.modelspace], openmode.forwrite);
using (blockreference bref = new blockreference(point3d.origin, idbtr))
{
btr.appendentity(bref);
t.addnewlycreateddbobject(bref, true);
}
t.commit();
}
}
}
}
对于块对像,除了将块分解外。还有没有其它方法取得块中对像。
lisp vba arx .net开发都会一点。可惜都不精。希望和大家共同学习进步。
在vb.net下插入块怎么写