This post is meant for those who are working on AutoCAD customization or interaction with AutoCad using DXF / DWG files.
RealDWG is just subset of ObjectARX hence not all the functionality is available with RealDWG. Another thing is ObjectArx can be used only when AutoCad is running, this is not the case with RealDWG. You can be working in a console based application where no UI is present.
During one of my assignments I came across a problem of reading entities fomr papespace layouts. This is not big deal you can get the layout block record and read the entities. But how to read the entities displayed in Paperspace Viewports ? This is the big problem with RealDWG library. In ObjectArx you can do it easily with selection sets as ui is running and complete set of functions are available with ObjectARX. Same is not true for RealdWG.
RealDWG solution.
1. Get the viewport boundary.
2. Map this boundary co-cordinates to modelsapce co-ordinates to locate the exact place where viewport is focused.
3. Now read all the entities from modelspace .
Identify entities outside the boundary, Inside boundary and on the boundary. You can do this by finding intersection with boundary, or point inside polygon etc. You need to take care for special cases such as circles, arcs, hatches, text othe othe complex entities having single referenc point.
4. Clip the entities which are on the boudary to generate exact paperspace view.
b