.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Extra viewport object in paperspace

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Ertqwa
493 Views, 3 Replies

Extra viewport object in paperspace

Hello Forum,

 

I have a drawing with a paperspace (AutoCAD 2016). In the paperspace I draw a rectangle. I use the command MVIEW to create a viewport of the rectangle (option OBJECT of the command MVIEW). Now the paperspace has 2 objects, the polyline and the viewport.

 

However, if I run the following code, it finds 3 objects. 1 polyline and 2 viewports:

 

// Get the BTR of the layout (paperspace).
objBlockTableRecord = objTransaction.GetObject(objLayout.BlockTableRecordId, OpenMode.ForRead) as BlockTableRecord;
oidcLayout = new ObjectIdCollection();
foreach (ObjectId oidItem in objBlockTableRecord)
{
   oidcLayout.Add(oidItem);
}
// oidcLayouts[0] = polyline.
// oidcLayouts[1] = viewport.
// oidcLayouts[2] = viewport.

 

Can anyone explain where the second viewport comes from? It does not exist in the drawing.

 

Thank you.

3 REPLIES 3
Message 2 of 4
_gile
in reply to: Ertqwa

Hi

 

Each Layout.BlockTableRecord contains its own viewport (with Number property equal to 1).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 4
ActivistInvestor
in reply to: Ertqwa


@Ertqwa wrote:

Hello Forum,

 

I have a drawing with a paperspace (AutoCAD 2016). In the paperspace I draw a rectangle. I use the command MVIEW to create a viewport of the rectangle (option OBJECT of the command MVIEW). Now the paperspace has 2 objects, the polyline and the viewport.

 

However, if I run the following code, it finds 3 objects. 1 polyline and 2 viewports:

 

Can anyone explain where the second viewport comes from? It does not exist in the drawing.

 

Thank you.


Each Layout is itself, like a Viewport. Commonly called the paper space viewport. That viewport displays the contents of paper space (e.g., the contents of the layout's block). When a paper space layout is active and you are in paper space, that paper space viewport is the active viewport. You can't see it's border because it is coincident with the client rectangle of the document window,.

 

 

Message 4 of 4
Ertqwa
in reply to: ActivistInvestor

Thank you for the answers. Just what I needed.

 

The following code filters out the viewport associated with the paperspace.

 

if (!dbActive.GetViewports(true).Contains(oidItem) || dbActive.GetViewports(false).Contains(oidItem))
{
   // Process oidItem.
}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report