我试图更改视口的属性,但代码总是在tr处崩溃。Commit();
- Database currentDatabase = HostApplicationServices.WorkingDatabase;
- Database db = new Database(false, true);
- db.ReadDwgFile(item.FileName, FileShare.ReadWrite, true, null);
- HostApplicationServices.WorkingDatabase = db;
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- ObjectId layoutId = Arx.SymTbl.GetDictionaryObject(item.LayoutName, db.LayoutDictionaryId, tr);
- Layout layout = (Layout)tr.GetObject(layoutId, OpenMode.ForWrite);
- BlockTableRecord psbtr = (BlockTableRecord)tr.GetObject(layout.BlockTableRecordId, OpenMode.ForWrite);
- foreach (ObjectId id in psbtr)
- {
- Entity ent = (Entity)tr.GetObject(id, OpenMode.ForWrite);
- if (ent is Viewport && id != db.PaperSpaceVportId)
- {
- Viewport vp = ent as Viewport;
-
- vp.Width = item.ViewPortPsWidth;
- vp.Height = item.ViewPortPsHeight;
- vp.CenterPoint = item.ViewPortPsCentePnt;
- vp.ViewCenter = item.ViewPortMsViewCenterPnt;
- vp.CustomScale = 1 / item.Scale;
-
- }
- }
- tr.Commit(); stop here
- }
- db.SaveAs(item.FileName, DwgVersion.Current);
- HostApplicationServices.WorkingDatabase = currentDatabase;
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |