Find the objects which are visible from current viewport using AutoCAD API C#

Find the objects which are visible from current viewport using AutoCAD API C#

kite15
Advocate Advocate
1,124 Views
1 Reply
Message 1 of 2

Find the objects which are visible from current viewport using AutoCAD API C#

kite15
Advocate
Advocate

Hi,

Can any one help to find the objects which are visible from the current viewport?

 

Since, my current layout name is "ABC" viewport id is "123456". Now, can I find the items which are completely in different list and partially in a different list, visible from from "ABC" layout and belongs from the viewport which have the id "123456"

 

Thanks and regards,

0 Likes
1,125 Views
1 Reply
Reply (1)
Message 2 of 2

norman.yuan
Mentor
Mentor

Basically what you need to do is find the Viewport's boundary points (assuming it is regular rectangle, then 4 corner points) and calculate their projected points in ModelSpace with proper transformation (Matrix3d). As long as your get the projected rectangle/polygon in ModelSpace, you can test which entities are inside the rectangle/Polygon.

 

Here is a relevant discussion where you can find good code for getting a Matrix3d to transform coordinates from PaperSpace to ModelSpace, or the other way around:

 

http://www.theswamp.org/index.php?topic=34590.msg398539#msg398539 

 

 

 

Norman Yuan

Drive CAD With Code

EESignature