将dwg插入当前cad窗口的代码[vc++]
www.dimcax.com
将dwg插入当前cad窗口的代码[vc++]
看到前面一位兄弟的vb代码,我也来一段; //插入图形 //cstring filename="c:\\xl\\43211234.dwg";//已经存在的文件 acdbdatabase* ptempdb=new acdbdatabase(false); ptempdb->readdwgfile(filename); acdbdatabase *tempdb; ptempdb->wblock(tempdb); acdbhostapplicationservices()->workingdatabase()->insert(acgematrix3d::kidentity,tempdb,true); delete ptempdb; [
acdbhostapplicationservices()->workingdatabase()->insert(acgematrix3d::kidentity,tempdb,true); 针对这一句我问个问题:在这段程序中,是直接insert, 43211234.dwg中的图元实体被分散地插入 ptempdb中 在c#。net中acgematrix3d::kidentity这个该用什么函数或者变量呢?、请会的兄弟指教下!谢谢
在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(); } } } } 这段不知道能否解决我上面的问题? objectid idbtr = doc.database.insert("test", db, false); 问题依然没有解决,这个也是作为块插入的,直接插入的函数该怎么设置呢?此处的“test”该换成什么呢? [