Viewport ".mspace" selection woes.

Discussion in 'AutoCAD' started by pkirill, Aug 18, 2004.

  1. pkirill

    pkirill Guest

    We have a routine that comes as close a you can get to "clicking a button" to create a drawing. It has worked flawlessly until a couple months ago. The process that breaks down goes like this:

    1) create main viewport
    2) activate that viewport and zoom to the proper area
    3) creat a keynote viewport
    4) activate that viewport and zoom to the proper keynote area
    5) activate the "primary" viewport and attach the background xref.

    What happens is that somehow the viewports are getting switched. Keynotes are showing up in the main viewport and work is showing up in the keynote viewport. On some machines the "main" viewport remains the "primary" viewport when running MSPACE. However, on others, it it does not. The code we're using is below.

    I can't seem to come up with a way to create a viewport, name it somehow and then specifically call it when I need to zoom in it...

    Any help would be greatly appreciated!!

    ; -----------------------------------------------------------
    ; Create the model space viewport (work)
    ; -----------------------------------------------------------
    (setq x1 (* NewConversionFactor (atof (dos_getini NewArea "x1" "H:\\2004\\04004\\Arch\\support\\Coords.ini"))))
    (setq x2 (* NewConversionFactor (atof (dos_getini NewArea "x2" "H:\\2004\\04004\\Arch\\support\\Coords.ini"))))
    (setq y1 (* NewConversionFactor (atof (dos_getini NewArea "y1" "H:\\2004\\04004\\Arch\\support\\Coords.ini"))))
    (setq y2 (* NewConversionFactor (atof (dos_getini NewArea "y2" "H:\\2004\\04004\\Arch\\support\\Coords.ini"))))
    (Setq ViewCenter (p_mid (list x1 y1 0) (list x2 y2 0)))

    (MakeLayer "X-Vprt" "7" "")
    (princ "\n*********************\nCreating MAIN Viewport\n*********************\n")
    (Command ".mview" (Strcat (rtos x1 2 8) "," (rtos y1 2 8)) (strcat (rtos x2 2 8) "," (rtos y2 2 8)))
    (command "change" "L" "" "P" "C" "4" "")
    ;(setq MainViewPort (entlast)) ;just something I was trying
    ;(Command ".layer" "Plot" "No" "X-Vprt" "Lock" "X-Vprt" "")

    ; -----------------------------------------------------------
    ; Zoom to the correct location & scale (work)
    ; -----------------------------------------------------------

    (Command ".mspace")
    (Command ".zoom" "1xp")
    (setq x1 (dos_getini NewArea "x" "H:\\2004\\04004\\Arch\\support\\Coords.ini"))
    (setq y1 (dos_getini NewArea "y" "H:\\2004\\04004\\Arch\\support\\Coords.ini"))
    (Command ".zoom" "c" (strcat x1 "," y1) "")


    ; -----------------------------------------------------------
    ; Attach the background xref
    ; -----------------------------------------------------------
    (Command ".mspace")
    (MakeLayer "X-Xref" "7" "")
    (Command ".xref" "a" NewXref "0,0" "1" "" "0")
    (Command ".Layer" "Lock" "X-Xref" "")
    (Command ".pspace")
     
    pkirill, Aug 18, 2004
    #1
  2. pkirill

    Paul Turvill Guest

    The system variable CVPORT contains the number of the current viewport.
    After creating your main viewport and switching to mspace, try
    (setq MainViewPort (getvar "cvport"));

    then, whenever you switch to ms after that point, you can force MainViewPort
    active with the call
    (setvar "cvport" MainViewPort)
    ___


    I can't seem to come up with a way to create a viewport, name it somehow and
    then specifically call it when I need to zoom in it...
     
    Paul Turvill, Aug 18, 2004
    #2
  3. pkirill

    pkirill Guest

    Well, I finally got back to trying to implement your solution and at first I
    only got to "half-work". I can get the setvar to assign the proper value to
    MainViewPort. However, using (setvar "CVPORT" MainViewPort) without an
    active viewport returns:
    Command: error: AutoCAD variable setting rejected: "CVPORT" 3

    However, this fixed it right up (command ".mspace")(setvar "CVPORT"
    MainViewPort)

    Thanks again for the eye-opener!
     
    pkirill, Aug 21, 2004
    #3
  4. pkirill

    Big 'D' Guest

    Could you add this to your template and revise viewport as needed after starting a new drawing? Just a thought.

    D
     
    Big 'D', Aug 23, 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.