isn't this...yet.
I try to make a viewport inside the layout..with height 10 in A3. It's very little viewport...and autocad return -1.
and the viewport is drawing in paper space
if the size Y-height increases 20 (example), return positive number and of course the viewport is ok.
there are a minimum size to build a viewport in paperspace ?
in my viewport buildin snapon =false..
I don't know where can i find a solution..
that's my code:
using (DocumentLock l = d.LockDocument())
{
using (Transaction t = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
{
Point3d pt1 = new Point3d(0, 0, 0);
Point3d pt2 = new Point3d(s.X, s.Y, 0);
Viewport vport = new Viewport();
vport.Height = (double)Math.Abs(pt1.Y - pt2.Y);
vport.Width = (double)Math.Abs(pt1.X - pt2.X);
// da controllare la sottrazione dei due vettori
//Vector3d ptc = pt2.GetAsVector().Subtract(pt1.GetAsVector());
vport.CenterPoint = new Point3d(pt2.X / 2, pt2.Y / 2, 0);
vport.SetDatabaseDefaults();
BlockTable bt = (BlockTable)t.GetObject(db.BlockTableId, OpenMode.ForWrite, false);
BlockTableRecord blkRec = (BlockTableRecord)t.GetObject(bt[BlockTableRecord.PaperSpace], OpenMode.ForWrite, false);
blkRec.AppendEntity(vport);
vport.On = true; // can't be set until after it is added to database
vport.SnapOn = false;
vport.Color = Autodesk.AutoCAD.Colors.Color.FromColor(System.Drawing.Color.Red);
{color:#ff0000}int vpNum = vport.Number;{color}
t.AddNewlyCreatedDBObject(vport, true);
t.Commit();
viewportID = vport.ObjectId;
}
return viewportID;
}
why the number is -1 when the viewport is created with a small size in y dimension ?
the same code if i try to build a viewport with Height 20 instead of 10 return vport.number > 0