Associate UCS w/ View in VBA (UCSVIEW)

Discussion in 'AutoCAD' started by spanqy, Jul 30, 2003.

  1. spanqy

    spanqy Guest

    UCSVIEW determines whether the current UCS is saved with a named view. When saving a view manually, this setvar works. It does not seem to work in VBA however:

    The following Sub creates the "MyView" view but fails to save the curent UCS with the view. What elese might I try?

    '***************************
    Sub CreatView()

    'Associate UCS w/ View
        Dim intUCSView As Integer
        Dim varCenterPt As Variant
        Dim dblCenter(1) As Double
        Dim objView As AcadView
        Dim objActViewPort As AcadViewport

    intUCSView = ThisDrawing.GetVariable("UCSVIEW")
    'save ucs w/ view
        ThisDrawing.SetVariable "UCSVIEW", 1

    'get current MS viewport center
        varCenterPt = ThisDrawing.GetVariable("VIEWCTR")
        dblCenter(0) = varCenterPt(0): dblCenter(1) = varCenterPt(1)

    Set objActViewPort = ThisDrawing.ActiveViewport

    'create View
        Set objView = ThisDrawing.Views.Add("MyView")
        With objView
            .center = dblCenter
            .Direction = ThisDrawing.GetVariable("VIEWDIR")
            .Height = objActViewPort.Height
            .Target = objActViewPort.Target
            .Width = objActViewPort.Width
        End With

    'restore ucsview value
        ThisDrawing.SetVariable "UCSVIEW", intUCSView
    End Sub
     
    spanqy, Jul 30, 2003
    #1
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.