Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have polyline close in model space . I want create viewport from this polyline, but I do'nt know how do.
You can help me?
Thank you very much!!!
This my code:
private void button1_Click(object sender, EventArgs e)
{
acad.Document _doc = acad.Application.DocumentManager.MdiActiveDocument;
Database db = _doc.Database;
Editor _ed = _doc.Editor;
//var ext = new Extents2d();
using (acad.DocumentLock _lock = _doc.LockDocument())
{
using (Transaction _tr = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)_tr.GetObject(db.BlockTableId, OpenMode.ForRead);
DBObjectCollection objs = new DBObjectCollection();
for (int i = 0; i < _ListKhungView.Count; i++)
{
Polyline _pl = _ListKhungView[i];
//Tạo layout mới
ObjectId id = LayoutManager.Current.CreateLayout("A" + i.ToString());
Layout lay = (Layout)_tr.GetObject(id, OpenMode.ForWrite);
// tạo 1 polyline copy
Polyline _plClone = _pl.Clone() as Polyline;
// Mở Block table record in paperSpace
BlockTableRecord ps = (BlockTableRecord)_tr.GetObject(lay.BlockTableRecordId, OpenMode.ForWrite);
ps.AppendEntity(_plClone);
_tr.AddNewlyCreatedDBObject(_plClone, true);
Viewport vp = new Viewport();
vp.SetDatabaseDefaults();
ps.AppendEntity(vp);
_tr.AddNewlyCreatedDBObject(vp, true);
vp.NonRectClipEntityId = _plClone.ObjectId;
vp.NonRectClipOn = true;
//vp.On = true;
vp.CustomScale = 1;
}
_tr.Commit();
}
acad.Application.UpdateScreen();
}
}
Solved! Go to Solution.