高手帮忙看看哪里出问题了?
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
namespace _01
{
public class Class1
{
public void closeAndSave()
{
Document doc;
Database db;
for (int i = 0; i <= 10; i++)
{
doc = newdwg();
using (DocumentLock docl = doc.LockDocument())
{
db = doc.Database;
dwl(db);
}
sclose(doc, i);
}
}
private void sclose(Document doc,int i)
{
doc.Database.SaveAs("d:\\00 dwg\\"+i+".DWG",DwgVersion.Current);
doc.CloseAndDiscard();
}
private void dwl(Database db)
{
Point3d p1 = Point3d.Origin;
double r = 100;
Circle c = new Circle();
c.Center = p1;
c.Radius = r;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt = tr.GetObject(db.BlockTableId,OpenMode.ForRead) as BlockTable;
BlockTableRecord btr=tr.GetObject(bt,OpenMode.ForWrite)as BlockTableRecord;
btr.AppendEntity(c);
tr.AddNewlyCreatedDBObject(c, true);
tr.Commit();
}
}
private Document newdwg()
{
string strTemplatePath = "acad.dwt";
DocumentCollection acDocMgr = Application.DocumentManager;
Document acDoc = acDocMgr.Add(strTemplatePath);
return acDocMgr.MdiActiveDocument = acDoc;
}
}
}
----------------------------
vs2010+CAD2012,运行时,每次得打开默认的文件才能保存一个新生成的文件,不知道哪里有问题了,请高手帮忙把脉。非常感谢
加载以后,每次得点击打开cad时默认的文件,程序才可以保存一个文件,不知道问题出在哪里,请各位大侠斧正,不胜感激。 commandflags.session 雪山飞狐_lzh 发表于 2017-10-20 12:21
commandflags.session
太棒了,谢谢飞狐大神,我的工具收官。就这点老是出错,以前老分不清楚DocumentLock 的范围,总是提示NoDocument,现在应该是弄清楚了,谢谢
页:
[1]