Get visible entities within irregular shaped Pviewport (Clipped Pviewport)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I am trying to get all entities within clipped viewport from paperspace,
to do this I am scrolling through all viewports in layout and activating each viewport and getting all entities within the activated viewport by translating coordinates to model space, this works fine if the viewport is rectangle but if i use same code to get entities from irregular shaped viewport (clipped viewport), it also returns the blocks/entities which are not visible in viewport.
objPViewPort.GetBoundingBox vpLL, vpUR
VPcenter = objPViewPort.Center
Width = objPViewPort.Width
Height = objPViewPort.Height
VpScale = CDbl(objPViewPort.CustomScale)
objPViewPort.GetBoundingBox MIN, MAX
ThisDrawing.ActivePViewport = activePviewport
MIN = ThisDrawing.Utility.TranslateCoordinates(MIN, 3, 2, False)
MAX = ThisDrawing.Utility.TranslateCoordinates(MAX, 3, 2, False)
varViewCtr = ThisDrawing.GetVariable("VIEWCTR")
CoordViewMin(0) = varViewCtr(0) - (Width / 2) / VpScale 'Min(0)
CoordViewMin(1) = varViewCtr(1) - (Height / 2) / VpScale 'Min(0)
CoordViewMin(2) = MIN(2)
CoordViewMax(0) = varViewCtr(0) + (Width / 2) / VpScale ''Max(0)
CoordViewMax(1) = varViewCtr(1) + (Height / 2) / VpScale ''Max(1)
CoordViewMax(2) = MAX(2)
For Each elem In ThisDrawing.ModelSpace
If elem.ObjectName = "AcDbBlockReference" Then
Set blk = elem
If VBA.UCase(blk.Name) = "BLK_NAME" Then
blk.GetBoundingBox blkLL, blkUR
If (blkLL(0) > CoordViewMin(0) And blkLL(0) < CoordViewMax(0)) And (blkLL(1) > CoordViewMin(1) And blkLL(1) < CoordViewMax(1)) Then
blkAttributes = blk.GetAttributes
End If
End If
End If
Next
any solutions?
Thank you!