Message 1 of 8
Not applicable
04-29-2013
02:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, have a problem.
There is a function that creates a few new layouts.
On each page i want to add viewport, but nothing action.
Insert Layouts
[CommandMethod("myAddLayout")]
public void GenerateLayouts()
{
int layoutCount = this.length / this.layoutLength;
using (Transaction tr = this.acCurDb.TransactionManager.StartTransaction())
{
LayoutManager acLayoutMgr = LayoutManager.Current;
for (int i = 0; i < layoutCount; i++)
{
// Create the new layout with default settings
String layoutName = i * this.layoutLength + " - " + (i + 1) * this.layoutLength;
ObjectId newLayoutId = acLayoutMgr.CreateLayout(layoutName);
Layout lay = tr.GetObject(newLayoutId, OpenMode.ForRead) as Layout;
CreateViewPort(lay.ObjectId);
}
tr.Commit();
}
}Insert ViewPort
public void CreateViewPort(ObjectId layoutId)
{
using (Transaction tr = this.acCurDb.TransactionManager.StartTransaction())
{
Layout layout = tr.GetObject(layoutId, OpenMode.ForRead) as Layout;
BlockTableRecord acBlkTblRec2 = tr.GetObject(layout.BlockTableRecordId, OpenMode.ForWrite) as BlockTableRecord;
// Create a Viewport
Viewport acVport = new Viewport();
acVport.SetDatabaseDefaults();
// Add the new object to the block table record and the transaction
acBlkTblRec2.AppendEntity(acVport);
tr.AddNewlyCreatedDBObject(acVport, true);
acVport.ViewDirection = new Vector3d(0, 0, 1);
// Enable the viewport
acVport.On = true;
// Save the new objects to the database
tr.Commit();
}
}But if call function - CreateViewPort, ViewPort is create on first page.
Solved! Go to Solution.