Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Am trying to assign a view in layout-viewport through Zoom-->object-->Single-->Groupname (from modelspace). the command execution is not working properly and also unable switch from modelspace to paperspace in layout
[CommandMethod("LayoutsViews")] public void LayoutsViews() { // Get the current document and database Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; acCurDb.TileMode = false; using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) { DBDictionary layoutIDs = acTrans.GetObject(acCurDb.LayoutDictionaryId, OpenMode.ForRead) as DBDictionary; // Reference the Layout Manager LayoutManager acLayoutMgr = LayoutManager.Current; // Step through and list each named layout and Model foreach (DBDictionaryEntry layoutID in layoutIDs) { Layout CurrentLo = acTrans.GetObject(layoutID.Value, OpenMode.ForRead) as Layout; string layoutName = CurrentLo.LayoutName.ToUpper().ToString(); if ((layoutName != "LAYOUT1") && (layoutName != "LAYOUT2") && (layoutName != "MODEL")) { //this.viewPort(CurrentLo, layoutName); ObjectIdCollection idCollection = CurrentLo.GetViewports(); foreach (ObjectId ID in idCollection) { Viewport VP = acTrans.GetObject(ID, OpenMode.ForRead) as Viewport; if (VP != null) { VP.UpgradeOpen(); VP.On = true; VP.SetDatabaseDefaults(); VP.Visible = true; // Activate model space in the viewport acDoc.Editor.SwitchToModelSpace(); string command = string.Empty; command = "._zoom _Object _SIngle _Group " + layoutName.ToString() + " "; acDoc.SendStringToExecute(command, true, false, true); acDoc.SendStringToExecute("._regen ", true, false, false); VP.UpdateDisplay(); break; } } } ////Activate model space in the viewport //acDoc.Editor.SwitchToPaperSpace(); } //Activate model space in the viewport // acDoc.Editor.SwitchToPaperSpace(); // Abort the changes to the database acTrans.Commit(); } }
Solved! Go to Solution.