How can I tell which viewport I am in

Discussion in 'AutoCAD' started by jonnoble, Jan 28, 2004.

  1. jonnoble

    jonnoble Guest

    Hi all,
    I am having a few problems and I think it comes down to a basic misunderstanding of viewports. I have some code that goes inserts a new layer and then goes through each layout in the drawing and freezes it in every layer except where the one the code was executed from. This means that a new layer can be added in one layout and it will not show in any others. Most of the code came from this discussion board. - Cheers

    However, if there is more than one viewport in a layout then it only turns it off in the selected viewport.

    Question. Is there anyway to select each viewport in a layout, or every veiwport in the drawing. Having been though the previous posts I guess it has something to do with xdata, but I am not sure. Any help would be greatly appreciated.

    Jon
     
    jonnoble, Jan 28, 2004
    #1
  2. jonnoble

    Jeff Mishler Guest

    Jon,
    If you can follow a lisp routine ( i don't know, since this was asked in the
    vab ng), I wrote one that does exactly what you are attempting and could
    give you a good idea where to go.....I'll post, if interested.

    Jeff

    misunderstanding of viewports. I have some code that goes inserts a new
    layer and then goes through each layout in the drawing and freezes it in
    every layer except where the one the code was executed from. This means
    that a new layer can be added in one layout and it will not show in any
    others. Most of the code came from this discussion board. - Cheers
    it off in the selected viewport.
    veiwport in the drawing. Having been though the previous posts I guess it
    has something to do with xdata, but I am not sure. Any help would be
    greatly appreciated.
     
    Jeff Mishler, Jan 28, 2004
    #2
  3. jonnoble

    Doug Broad Guest

    Jon,
    Wouldn't using sendcommand to send "vplayer" "newfreeze" and
    then "vplayer" "thaw" "" work for you?

    Regards,
    Doug


    a new layer and then goes through each layout in the drawing and freezes it in every layer except where the one the code was
    executed from. This means that a new layer can be added in one layout and it will not show in any others. Most of the code came
    from this discussion board. - Cheers
    posts I guess it has something to do with xdata, but I am not sure. Any help would be greatly appreciated.
     
    Doug Broad, Jan 28, 2004
    #3
  4. jonnoble

    Mark Propst Guest

    Option Explicit

    Sub CycleVports()
    Dim odoc As AcadDocument
    Set odoc = ThisDrawing
    Dim oVp As AcadPViewport
    odoc.ActiveSpace = acPaperSpace
    odoc.MSpace = False
    Dim olyt As acadlayout
    Dim olyts As acadlayouts
    Dim oent As AcadEntity
    Set olyts = odoc.layouts
    Dim icount As Integer

    For Each olyt In olyts
    icount = 0
    If olyt.Name <> "Model" Then
    odoc.ActiveLayout = olyt
    odoc.MSpace = False
    MsgBox olyt.Name

    For Each oent In olyt.Block
    If TypeOf oent Is AcadPViewport Then
    icount = icount + 1
    Set oVp = oent
    oVp.Display (True)
    odoc.MSpace = True

    On Error Resume Next
    odoc.ActivePViewport = oVp
    If Err Then
    icount = icount - 1
    Err.Clear
    odoc.MSpace = False
    'MsgBox "paper space can't be active viewport!"
    Else
    MsgBox "this one's active"
    End If
    odoc.MSpace = False
    End If
    Next
    MsgBox "Found " & icount & " viewports on " & olyt.Name
    End If
    Next
    'set stuff to nothing

    End Sub

    hth
    Mark

    viewports? I have several VP's on each layout, and need to be able to
    select each one!
    can't do it and haven't found anyone else who knows how to in VB.
    the server because it is too big. I expect due to our time difference that
    you will have replied before I have posted, but hey!
     
    Mark Propst, Feb 12, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.