![]() |
【转帖】[求助]c#打开acad图纸出错??
[求助]c#打开acad图纸出错??
www.dimcax.com [求助]c#打开acad图纸出错?? 我在执行下面代码打autocad图纸时 acaddoc = acad.documents.open(strfilename,false,null); acadspace = acaddoc.modelspace 在执行到第2句时 发生 {system.runtime.interopservices.comexception} 类型的异常 请教这个怎么办啊?? -------------------------------------- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 using system; using system.windows.forms; using system.data; using system.runtime.interopservices; using system.data.sqlclient; using vba; using autocad; namespace foton.ov.pdmsign { /// <summary> /// autocad签字组件(类) /// </summary> public class signtodwg { #region autocad签字过程 /// <summary> /// autocad签字过程 /// </summary> /// <param name="strfilename">图纸名称(包括路径)</param> /// <param name="strsigntoname">签字名称</param> /// <param name="point">签字位置(相对标题框右下角)</param> public static void signprocess(string strfilename,string strsigncontent,double[] point) { autocad.acaddocument acaddoc; autocad.acadmodelspace acadspace; autocad.acadblockreference blockref; double[] blockpoint = new double[3]; double[] txtxpointmin = new double[3]; acaddoc = acad.documents.open(strfilename,false,null);//打开一个autocad文档,password为"" acadspace = acaddoc.modelspace;//模型 ..... } #endregion } } 同样的问题我也发过了,这个论坛上都是牛人,这种事没人理啊.... 你的 acad.documents.open(...); 是怎么定义的, 我用下面的代码就可以: autocad.acadapplication cad; autocad.acaddocument acaddoc; autocad.acadmodelspace acadspace; cad = (acadapplication)system.runtime.interopservices.marshal.getactiveobject("autocad.application.16"); acaddoc = cad.documents.open(strfilename,false, null) acadspace = acaddoc.modelspace; messagebox.show(acadspace.count.tostring()); private acadapplication a ; autodesk.autocad.interop.acadapplication a; autodesk.autocad.databaseservices.database db; private void form1_load(object sender, system.eventargs e) { this.pt1.text="1,1,1"; this.pt2.text="122,122,122"; a = new acadapplicationclass(); this.acaddoc=a.documents.open(@"c:\test.dwg", null, null); //本条语句自动打开一个图形文件 a.zoomall(); //图形文件实行全局缩放; 最好用autocad |
所有的时间均为北京时间。 现在的时间是 04:23 AM. |