.NET

Reply
Active Contributor
harryliu3140
Posts: 46
Registered: ‎10-29-2009
Message 1 of 4 (440 Views)
Accepted Solution

Invisible viewport

440 Views, 3 Replies
08-22-2013 07:14 AM

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

 

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

 

Thank you, Jeff

*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 2 of 4 (432 Views)

Re: Invisible viewport

08-22-2013 08:15 AM in reply to: harryliu3140

did you check if the obj.iserased ?

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



(defun botsbuildbots() (botsbuildbots))
Valued Mentor
jeff
Posts: 330
Registered: ‎05-12-2009
Message 3 of 4 (427 Views)

Re: Invisible viewport

08-22-2013 08:48 AM 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
Active Contributor
harryliu3140
Posts: 46
Registered: ‎10-29-2009
Message 4 of 4 (372 Views)

Re: Invisible viewport

09-26-2013 10:26 AM in reply to: harryliu3140

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

 

Thank you, Jeff

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.