Paperspace Viewports

Discussion in 'AutoCAD' started by milfora, Mar 30, 2005.

  1. milfora

    milfora Guest

    I have setup an event procedure which is activated when the user enters a floating modelspace window (command MSPACE). What I want is for the program to return the properties of the viewport the user has entered (ie. CustomScale, Height, Width etc)

    The following code does not appear to work, as the ActivePViewport returned is that of the actual Paperspace layout.

    Is there a way to set the active pviewport to the viewport the user enters on the MSPACE command?

    Public Sub Floating_Modelspace_DwgScale(X)

    ' declare variables
    Dim oPViewport As AcadPViewport
    Dim Scl, Width, Height As Single

    Set oPViewport = ThisDrawing.ActivePViewport
    oPViewport.Display (True)

    Scl = oPViewport.CustomScale
    Width = oPViewport.Width
    Height = oPViewport.Height

    End Sub


    Thanks in advance

    AM
     
    milfora, Mar 30, 2005
    #1
  2. milfora

    Jeff Mishler Guest

    How is your Event fired?

    The following works for me in R2002...

    Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
    Select Case UCase(CommandName)
    Case Is = "MSPACE"
    Floating_Modelspace_DwgScale (CommandName)
    End Select
    End Sub


    Public Sub Floating_Modelspace_DwgScale(X)

    ' declare variables
    Dim oPViewport As AcadPViewport
    Dim Scl, Width, Height As Single

    Set oPViewport = ThisDrawing.ActivePViewport
    oPViewport.Display (True)

    Scl = oPViewport.CustomScale
    Width = oPViewport.Width
    Height = oPViewport.Height
    MsgBox "Scale = " & Scl & vbCrLf & "Width = " & Width & vbCrLf & "Height
    = " & Height
    End Sub
     
    Jeff Mishler, Mar 31, 2005
    #2
  3. milfora

    milfora Guest

    Jeff,

    Thanks for the quick response.

    My event was fired from the AcadDocument_BeginCommand event. Code shown below:

    Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
    On Error Resume Next
    ' check for following cases
    Select Case CommandName

    Case "MSPACE"
    ' if user enters a floating modelspace window
    Floating_Modelspace_DwgScale 1

    End Select

    End Sub

    I have just put the calling procedure in the wrong event (should have been the AcadDocument_EndCommand event)

    This has fixed the problem nicely
    Thanks again
     
    milfora, Mar 31, 2005
    #3
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.