- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I am having a slight problem in my C# NET code and I am hoping someone can point me in the right direction.
So far I have successfully written code to take a polyline from modelspace and use it to create a clipped viewport of the area in a new layout.
My problem arises when I try to rotate this viewport afterwards (if it is taller than it is wide).
Here is a snippet of the code after I have opened the viewport for write within the transaction...
note: 'pl' is a polyline in paper space that has been scaled from the original polyline in modelspace
Viewport acVport = (Viewport)vpId.GetObject(OpenMode.ForWrite, true);
Point3d centerPoint = pl.Center();
acVport.Width = pl.Bounds.Value.MaxPoint.X - pl.Bounds.Value.MinPoint.X;
acVport.Height = pl.Bounds.Value.MaxPoint.Y - pl.Bounds.Value.MinPoint.Y;
Point2d a = new Point2d(acVport.Bounds.Value.MaxPoint.X, acVport.Bounds.Value.MaxPoint.Y);
Point2d b = new Point2d(acVport.Bounds.Value.MinPoint.X, acVport.Bounds.Value.MinPoint.Y);
Point2d pSpaceVpCenter = (a.Add(b)) / 2.0;
acVport.ViewDirection = new Vector3d(0, 0, 1);
acVport.CenterPoint = new Point3d(centerPoint.X, centerPoint.Y, 0);
acVport.CustomScale = 0.01;
pl.TransformBy(Matrix3d.Displacement(pSpaceDisplacementVector));
acBlkTblRec.AppendEntity(pl);
acTrans.AddNewlyCreatedDBObject(pl, true);
acVport.NonRectClipEntityId = pl.ObjectId;
acVport.NonRectClipOn = true;
acVport.ViewCenter = new Point2d(modelCenter.X, modelCenter.Y);
bool landscapeOriented = (acVport.Bounds.Value.MaxPoint.X - acVport.Bounds.Value.MinPoint.X) >= (acVport.Bounds.Value.MaxPoint.Y - acVport.Bounds.Value.MinPoint.Y);
if (!landscapeOriented)
{
acDoc.Editor.WriteMessage("Rotating Viewport... (90 deg CC)\n");
Matrix3d acMat3d = Matrix3d.Rotation(Math.PI / 2.0, Vector3d.ZAxis, acVport.Bounds.Value.MinPoint);
// rotate 90 degrees (counter clockwise)
acVport.TransformBy(acMat3d);
}
acTrans.Commit();
Everything works as desired except for the final transformation (the 90 degree rotation). The editor does spit out the message "Rotating Viewport... (90 deg CC)", so I know the block is being executed. Does anyone know why this transformation is not actually happening to the paper-space viewport? Any advice is greatly appreciated!
Solved! Go to Solution.