.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
viewport Number -1 ?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
287 Views, 5 Replies
02-12-2009 01:09 AM
Hi, I have created 2 viewport in my layout via code.
1 of this , has property Number -1. No one error during creation ...but it's have number -1. Object id is valid.
Then when i try to get it in writemode an error occurred. Any suggestion ?
1 of this , has property Number -1. No one error during creation ...but it's have number -1. Object id is valid.
Then when i try to get it in writemode an error occurred. Any suggestion ?
Re: viewport Number -1 ?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-12-2009 01:43 AM in reply to:
bikelink
If the size of viewport is >= of layout dimension -1 si returned
as soon you have created a viewport with dimension inside layout the number increase...
example:
1 layout 210x297
creation viewport with same size--> -1 returned
creation viewport with same size--> -1 returned
creation viewport size 205x290 . --> 4 or 5.
Well, the viewport internal is numbered but autocad don't show us the index , until he (you..) drawing inside the layout.
I think that is a bug. If I need to create a viewport outside the layout (and autocad allows this.) autocad must to number all the viewports
created. Please tell me if i wrong..
as soon you have created a viewport with dimension inside layout the number increase...
example:
1 layout 210x297
creation viewport with same size--> -1 returned
creation viewport with same size--> -1 returned
creation viewport size 205x290 . --> 4 or 5.
Well, the viewport internal is numbered but autocad don't show us the index , until he (you..) drawing inside the layout.
I think that is a bug. If I need to create a viewport outside the layout (and autocad allows this.) autocad must to number all the viewports
created. Please tell me if i wrong..
Re: viewport Number -1 ?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-12-2009 03:21 AM in reply to:
bikelink
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.Data base.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.Dra wing.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
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.Data
{
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.
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.Dra
{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
Re: viewport Number -1 ?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-12-2009 05:16 AM in reply to:
bikelink
OK....i don't understood ...the zoom in paper space is the base of my trouble.
if you look from distant the layout, the viewports with a little size aren't numbered!
if you perform a zoom in paper space..or better a zoom with the angle of your viewport in creation...then the number will be correct.
the right sequence is
create layout
zoom extension in paper space (but if you have an A0/A1 and some little viewport this couldn't be are enough)
better zoom on your size viewport.
creation viewport. the number is right.
thanks autocad...for this joke..
if you look from distant the layout, the viewports with a little size aren't numbered!
if you perform a zoom in paper space..or better a zoom with the angle of your viewport in creation...then the number will be correct.
the right sequence is
create layout
zoom extension in paper space (but if you have an A0/A1 and some little viewport this couldn't be are enough)
better zoom on your size viewport.
creation viewport. the number is right.
thanks autocad...for this joke..
Re: viewport Number -1 ?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-18-2012 03:40 PM in reply to:
bikelink
Excellent!
Sorry to bring an old thread back from the dead, but I just ran into this exact issue!
My newly created viewports were comining up with the number of -1. After doing a zoom extents on the new layout (prior to creating the new viewports), the viewports are numbered properly and I no longer get an error!!
Thanks for figuring this out bikelink!
Re: viewport Number -1 ?
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-19-2012 11:16 AM in reply to:
bikelink
İ am confused a little. arent ViewPortTableRecords member of ViewPortTable ?
