Hi,
Search for "Viewports" in the Developer's guide and you will find this explanation explaining the ViewportTableRecord and the Viewport. In paperspace, you will only find Viewports and not ViewportTableRecord.
<<<<
A viewport is a particular view of the drawing file, either in model space (TILEMODE=1) or paper space (TILEMODE=0). In model and paper space, viewports have different properties and are represented by objects of different types.
The current model space viewport configuration is contained in the AcDbViewportTable symbol table. The viewports in this configuration are represented by AcDbViewportTableRecord objects. Saved viewport configurations are contained in the AcDbViewTable symbol table and their views are represented by AcDbViewTableRecord objects. The model space viewports are always rectangular.
In a paper space layout, viewports are represented by AcDbViewport objects. These viewports can be complex clipped, that is they can be set to any arbitrary shape. In paper space, unlike model space, viewports do not need to be tiled. AcDbLayout objects, accessed from the ACAD_LAYOUT named object dictionary, describe the viewport configuration for that layout.
>>>>
There is a known issue in setting the UCS for a Viewport using its SetUCS method. As a workaround, set it using the COM API as shown in the sample code. You can modify it based on ECS value.
[CommandMethod("SetUCS")]
public void SetViewportUcs()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor oEd = Application.DocumentManager.MdiActiveDocument.Editor;
AcadPViewport acadViewport = null;
AcadDocument acadDoc = doc.AcadDocument as AcadDocument;
acadDoc.ActiveLayout = acadDoc.Layouts.Item("Layout1");
//Reference the ViewPort object on Layout (the ActiveLayout)
if (acadDoc.PaperSpace.Item(1).ObjectName == "AcDbViewport")
{
acadViewport = acadDoc.PaperSpace.Item(1) as AcadPViewport;
}
//Make sure the Viewport is displayed and on
acadViewport.Display(true);
acadViewport.ViewportOn = true;
//Before making a pViewport active the mspace property needs
//to be True for a floating viewport
acadDoc.MSpace = true;
acadDoc.ActivePViewport = acadViewport;
acadDoc.Regen(AcRegenType.acActiveViewport);
Matrix3d newUcsMat = Matrix3d.AlignCoordinateSystem(new Point3d(0, 0, 0), new Vector3d(1, 0, 0), new Vector3d(0, 1, 0), new Vector3d(0, 0, 1),
new Point3d(0, 0, 0), new Vector3d(0, 1, 0), new Vector3d(-1, 0, 0), new Vector3d(0, 0, 1));
oEd.CurrentUserCoordinateSystem = newUcsMat;
}
Balaji
Developer Technical Services
Autodesk Developer Network