Hi, Experts of ObjectARX
I have a function to find all the viewports on a layout and fill the viewport list. But the routine finds viewport which is not exist in the layout. The invisible viewport seems can’t be deleted or the drawing file can’t be open properly. Maybe they are fundamental of those visible viewport. How can I detect this character? The function is listed behind.
Thanks to all attention.
Public Function FindViewport(mylay As Layout, btr As BlockTableRecord, ByRef vplist As List(Of Viewport)) As Viewport Dim id As ObjectId Dim basepoint As Point3d = New Point3d(0, 0, 0) Dim insertpoint As Point3d = New Point3d(0, 0, 0) Dim uprt, btlt As Point3d Dim viewuprt, viewbtlt As Point3d Dim layid As ObjectId = btr.OwnerId Dim viewidcollection As ObjectIdCollection vplist.Clear() viewidcollection = mylay.GetViewports uprt = mylay.Extents.MaxPoint btlt = mylay.Extents.MinPoint FindViewport = Nothing For Each id In viewidcollection FindViewport = id.GetObject(Autodesk.AutoCAD.DatabaseServices.Ope
nMode.ForWrite, True) viewuprt = FindViewport.CenterPoint.Add(New Vector3d(FindViewport.Width / 2, FindViewport.Height / 2, 0)) viewbtlt = FindViewport.CenterPoint.Add(New Vector3d(-FindViewport.Width / 2, -FindViewport.Height / 2, 0)) vplist.Add(FindViewport) Next End Function
Solved! Go to Solution.
did you check if the obj.iserased ?
Your probably mean the paperspace viewport.
Each paperspace layout has viewport and you maybe think of it as the one that shows the paper background and you add "floating" viewports which give a view to modelspace.
If you look at description of Layout.GetViewports in docs
This function returns a collection of ObjectIds of all the Viewports that exist in the Layout's paperspace. The first ID in the list will be the paperspace viewport. If the list returned is empty, then this Layout has never been switched to (activated). The list is updated each time a layout is activated, and kept up-to-date while that layout is active (whenever viewports are added or deleted).
There is also Database.GetViewports which takes a boolean argument
Start with some of our most frequented solutions to get help installing your software.