Named Views

Discussion in 'AutoCAD' started by Dan, Oct 8, 2004.

  1. Dan

    Dan Guest

    Ok, I have tried to reaserch the help files, and the NG, but I have yet to
    determine why when I create a namved view via:

    Set viewObj = ThisDrawing.Views.Add("currentview")

    The view thats created does not have the same view as if I did it from the
    command prompt.

    -view;s;currentview; <---------------This is the outcome I want

    I just want the current view to be created. It seams the ceter point is
    always different.

    ??????

    Thanks for clearing this up,
    Dan
     
    Dan, Oct 8, 2004
    #1
  2. Dan

    Dan Guest

    Clarification-
    I know I can simply use the send command, but I do not wish to. I know you
    can define a centerpoint, but how can this be done if your view changes all
    the time. The location will be determined as the user initiate the macro,
    then I wish to run some code, and return the user to where they started.
    Then the view is deleted, so it is not a permanent.

    Any ideas?
    Thanks,
    Dan
     
    Dan, Oct 8, 2004
    #2
  3. Dan

    Jeff Mishler Guest

    Use ThisDrawing.GetVariable for both the "viewctr" & "viewsize" to set the
    Center & Height properties of the view. Be careful though, as the viewctr
    returns a 3d point and the Center property expects a 2d point.
     
    Jeff Mishler, Oct 9, 2004
    #3
  4. Dan

    Dan Guest

    Hmm,
    Not getting past this line:

    vCtr = ThisDrawing.GetVariable("viewctr")

    What am I doing wrong here?
    This is a start, not finished yet obviously, but I am trying to incorporate
    the view center,
    and I am not sure about how to define the current view size.
    Thanks,
    Dan



    Sub test_view()

    Dim viewObj As IAcadView2
    Dim dCPt(1) As Double
    Dim vCtr As String
    Dim vSize As String

    vCtr = ThisDrawing.GetVariable("viewctr")
    vSize = ThisDrawing.GetVariable("viewsize")

    dCPt(0) = 6
    dCPt(1) = 6
    Set viewObj = ThisDrawing.Views.Add("TEST")
    With viewObj
    .Center = vCtr
    '.Height = 4.5
    '.Width = 4.5
    End With
    End Sub
     
    Dan, Oct 11, 2004
    #4
  5. Sub test_view()

    Dim viewObj As IAcadView2
    Dim dCPt(1) As Double
    Dim vCtr As Variant 'Modified by Nathan
    Dim vSize As String

    vCtr = ThisDrawing.GetVariable("viewctr")
    vSize = ThisDrawing.GetVariable("viewsize")

    dCPt(0) = vCtr(0) 'Modified by Nathan
    dCPt(1) = vCtr(1) 'Modified by Nathan
    Set viewObj = ThisDrawing.Views.Add("TEST")
    With viewObj
    Center = dCPt 'Modified by Nathan
    '.Height = 4.5
    '.Width = 4.5
    End With
    End Sub
     
    Nathan Taylor, Oct 12, 2004
    #5
  6. Dan

    Dan Guest

    I appreciate the help, but I am not understanding.

    I cannot seem to get the code to work.

    -view;s;currentview; <---------------This is the outcome I want, manually
    entered from command line.
    What is the VB equivilant?
     
    Dan, Oct 12, 2004
    #6
  7. Dan

    Dan Guest

    Still no go....
    Any ideas?
     
    Dan, Oct 13, 2004
    #7
  8. The info you recv'd through the other posts is close but not quite there.
    In order to get the exact view, you MUST supply a height AND WIDTH -
    otherwise AutoCAD extrapolates the size for you. So, to solve this problem
    we'll use basic geometry. We can get the AREA variable which stores the
    area of the current view. Since A = L x W, we'll just solve for W since we
    know the area and the height:

    Sub ReCreateCurrentView()
    Dim oV As AcadView
    Dim vCPt As Variant
    Dim dArea As Double
    Dim dHgt As Double
    With ThisDrawing
    vCPt = .GetVariable("VIEWCTR")
    dHgt = .GetVariable("VIEWSIZE")
    dArea = .GetVariable("AREA")
    Set oV = .Views.Add("DAN")
    ReDim Preserve vCPt(1)
    oV.Center = vCPt
    oV.Height = dHgt
    oV.Width = dArea / dHgt
    End With
    End Sub

    Notice that the view requires a 2D point but the VIEWCTR variable returns a
    3D point. I am redefining the variable with the preserve option to convert
    the 3D point to 2D.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Oct 14, 2004
    #8
  9. Oops....I should add that this will only work if the user hasn't used the
    AREA command. The Area variable stores the area of the current view until
    someone uses the area command and then it retains that area. So, if your
    users use the area command, you're stuck with the extrapolated view unless
    someone else has a better workaround.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Oct 14, 2004
    #9
  10. Dan

    Dan Guest

    Thank you very much gentlemen,
    I have been learning from the school of hard knocks, and have just recently
    been given the support to really dive into learning VB, and obtaining the
    materials necessary. These Newsgroups, and help files have been the source
    of my education, and I have learned very much by example. I have been using
    AutoCAD for over 12 years, but never dove into the VB side of things....WOW!

    I really do appreciate your time, and sharing to help others like myself.

    I hope to be able to contribute back soon.

    Thanks again,
    Dan
     
    Dan, Oct 14, 2004
    #10
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.