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

Invisible viewport

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
harryliu3140
1037 Views, 3 Replies

Invisible viewport

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.

Harry

    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.OpenMode.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

 

3 REPLIES 3
Message 2 of 4
arcticad
in reply to: harryliu3140

did you check if the obj.iserased ?

---------------------------



(defun botsbuildbots() (botsbuildbots))
Message 3 of 4
jeff
in reply to: harryliu3140

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

Input flag indicating whether to return paperspace viewports associated with layouts 

 

You can also find your answers @ TheSwamp
Message 4 of 4
harryliu3140
in reply to: harryliu3140

I just got a chance to try Jeff's suggestion. It's works all right now.

 

Thank you, Jeff

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost