Mview Fit doesn't, erm... fit...

 I have, what some peeps may think, a strange way of working. I create layout tabs and fill each one with a viewport. Each viewport fills the screen and I set the view to suit my most popular views. So, one for plan, one for front, one for left. And I might have one which is rendered.

I have a lisp routine that creates these tabs for me. It uses the Mview > Fit command, but the created viewport does not fill the working area of the layout. Regardless of where I am zoomed, it always creates a viewport which is 257 wide and 195 high and the lower left corner is positioned at 0,0

The help file for this command says "Draws a rectangular viewport that fits the current layout."

Okay, not a show breaker, obviously, but why have an Mview > Fit option if it doesn't do what it is supposed to?

cheers

andy

Comments

  • Your 'strange way of working' sounds in teresting. Maybe in a separate topic, can you say more about how you make use of that?
  • IMO the 'Fit' option does exactly what it is supposed to do. It's results depend on the selected printer and paper size of the layout. The result you are getting is based on an A4 sheet with print margins.
  • Maybe you have DISPPAPERBKG set to 0. Changing it to 1 will clarify the issue.
  • Your 'strange way of working' sounds in teresting. Maybe in a separate topic, can you say more about how you make use of that?

    Yes, I will do that, because there is one main reason that mattered to the way I work, so, I'll write something up to explain and either post here or send you a PM (assuming we can do that here).

    cheers

    andy
  • Maybe you have DISPPAPERBKG set to 0. Changing it to 1 will clarify the issue.

    Hi Roy,

    Thanks for replying to this topic :)

    I tried typing that variable in the command line but I got the following:-

    "Undocumented variable. Cannot be modified on the commandline"

    I am assuming that you mean to display the paper background, and when I tick that box then, yes, I see what you mean.

    But, BCAD is being sold to me as a close competitor to ACAD and in the latter, when you invoke Mview > Fit, you get a viewport that fills the whole screen, which is what I want to happen in BCAD and the help file suggests that it does.

    I suppose I really need to explain further what I am trying to do here:-

    For a long time now I have been modelling in 3D. I have always disliked using tiled viewports because I want to always see as much of my model as possible at all times, despite the advantages of having a split screen.

    Before tabs were created, well, that's so long ago now that I can't remember how I coped, but, once Tabs did come along I jumped on the idea that I could use tabs to hold a single viewport each. then to flip between different view points all I had to do was click on a tab.

    I guess that most peeps are used to just clicking the gizmo at the top right of the screen to quickly switch view points, but I do not like the way that each time you change your view point the model view zooms out to its extents. I found that, by using tabs with viewports, I could zoom into a particular area of the model in each view point (viewport) and then quickly switch between those view points (viewports) and remain focused on the task at hand.

    I found this essential when working on models that spanned hundreds of metres.

    Might sound weird but, for me, it works.

    So, that is why I would like the Mview > Fit command to work the same as it does in AutoCAD, if that is possible.

    A quick word about paper backgrounds and print area... The very first thing I do when setting up my system is I turn of the auto creation of viewports in new tabs, I turn all backgrounds to black and I turn off print area. I just prefer things that way.

    As much of an extinct dinosaur I sound there, I do like my ribbons, unlike some of my colleagues who instantly turn them off and revert to icons.

    I guess that's one of the beauties of both ACAD and BCAD, we can use then however we want :-)


    cheers

    andy
  •  @Tom,

    I realise we can't send PM's here, or edit posts. I tried to contact you on Linkedin but I'm not a premium member.

    Anyway, I hope my reply to Roy's post explains why I use viewports in tabbed views. If you need to discuss further, reply to this and I'll do my best to clarify any unclear points.

    cheers

    andy
  • Here is some Lisp code that may help:
    [code](defun c:MviewFit ( / doc lst)
      (setq doc (vla-get-activedocument (vlax-get-acad-object)))
      (vla-endundomark doc) ; End open undo group.
      (vla-startundomark doc)
      (setq lst (acet-geom-view-points)) ; Points are in current UCS.
      (setvar 'cmdecho 0)
      (command "_.mview" "_non" (car lst) "_non" (cadr lst))
      (setvar 'cmdecho 1)
      (vla-endundomark doc)
      (princ)
    )[/code]
  • Damn, Roy is too fast for me again :-)

    Here's my take
    [code]; Return a list giving the bottom & top coordinates of the current screen
    (defun SCREENDIMS ( / Vheight Screen Ratio Vwidth Vctr)
        (setq VHeight (getvar 'VIEWSIZE))
        (setq Screen (getvar 'SCREENSIZE))
        (setq ratio (/ VHeight (cadr Screen)))
        (setq VWidth (* (car Screen) ratio))
        (setq Vctr (getvar 'VIEWCTR))
        (List
            (list (- (car vctr) (* 0.5 Vwidth)) (- (cadr vctr) (* 0.5 VHeight)))
            (list (+ (car vctr) (* 0.5 Vwidth)) (+ (cadr vctr) (* 0.5 VHeight)))
        )
    )

    ;Create an MVIEW to fit the current screen size
    (defun C:MVIEW-FIT ( / ScreenCoords)
        (acet-sysvar-set '("CMDECHO" 0 "OSMODE" 0))
        (setq ScreenCoords (SCREENDIMS))
        (if (and (= 0 (getvar 'TILEMODE)) (= 1 (getvar 'CVPORT)))
            (command "._MVIEW" (car ScreenCoords) (cadr ScreenCoords))
            (princ "\nCan't create VPORT in Model Space")
        )
        (acet-sysvar-restore)
        (prin1)
    )[/code]

    I assume the OP refers to an earlier version of AutoCAD. These days the Paperspace size has become more entwined with the printer paper size applied to the layout. The default in AutoCAD is also to create a MVIEW FIT that is equal to the printable area. You need to turn the display of this of to get it to go to the limits of the window size. In BricsCAD turning off the display of the printable area DISPPAPERMARGINS didn't change anything, hence the LISP.

    As the size of the created viewport isn't important in this case, an alternative approach could be to create a viewport based on the SCREENSIZE, then simply zoom in on it.

    If your using a layout in this way you will probably want the paper background and printable area turned off. You can't do this from the command line, but you can from LISP:
    (setvar 'DISPPAPERMARGINS 0)
    (setvar 'DISPPAPERBKG 0)

    It would be nice if you could tear a layout off to display in its own window. This would allow you to make really good use of having multiple monitors.

    Regards,
    Jason Bourhill

  •  Hi Roy and Jason,

    Thanks so much for the code.

    In the meantime I have raised a ticket.


    I'm currently out of work so I cannot get my hands on AutoCAD, but up to the middle of April I was using V16 and Mview > Fit behaved exactly as I explained.

    And regarding turning off paper background and displaying printable area, as I explained in one of my posts above, I turn these off via the display settings in the settings dialog box. I do this even if I am using a layout tab for a drawing. I just prefer it that way.

    cheers, and thanks again, I appreciate your input :-)

    andy
  • I'm currently out of work so I cannot get my hands on AutoCAD, but up to the middle of April I was using V16 and Mview > Fit behaved exactly as I explained.


    I meant that in AutoCAD 2016 if you have the 'printable area' on, then  MVIEW Fit works in the same manner as BricsCAD. This is the default out of the box state for both applications.


    Regards,
    Jason Bourhill



  • I meant that in AutoCAD 2016 if you have the 'printable area' on, then  MVIEW Fit works in the same manner as BricsCAD. This is the default out of the box state for both applications.


    Regards,
    Jason Bourhill


    Ah, I see, thanks for putting me right on that Jason.

    I'll be honest, I've never understood of liked either the paper or print area display or, indeed, backgrounds other than black... I guess I'm a bit of a stick in the mud haha!

    Thanks again for the code above. My lisp writing days are pretty much over. I used to be up all night long in my earlier years coming up with new scripts for this and that. I also spent ten years as the AutoPLANT administrator for a large corporate company, but I'm finding that, at 56, I'm struggling to keep up with things.

    cheers

    andy
  •  Okay... I've adapted my very old code by stripping out stuff that doesn't work and incorporating Roy's "MviewFit" code from above (because it was a few lines less than Jason's)

    [code]
    ; C:TABS is used to set up three new layout tabs called Plan View,
    ; North View and East View:-

    (defun C:TABS ()
      (command "_.LAYER" "S" "0" "")
      (do_plan_tab)
      (do_north_tab)
      (do_east_tab)
      (command "_.LAYOUT" "S" "Model")
      (princ)
    )

    ; C:TABR is used to re-set the Plan, North and East View layout tabs
    ; if the screen size has changed:-

    (defun C:TABR ()
      (command "_.LAYER" "S" "0" "")
      (command "_.LAYOUT" "D" "Plan View")
      (do_plan_tab)
      (command "_.LAYOUT" "D" "North View")
      (do_north_tab)
      (command "_.LAYOUT" "D" "East View")
      (do_east_tab)
      (command "_.LAYOUT" "S" "Model")
      (princ)
    )

    (defun do_plan_tab ()
      (command "_.TILEMODE" "1")
      (command "_.VPOINT" "R" "215" "25")
      (command "_.LAYOUT" "N" "Plan View")
      (command "_.LAYOUT" "S" "Plan View")
      (MviewFit)
      (command "_.MSPACE")
      (command "_.UCS" "W")
      (command "_.PLAN" "")
    )

    (defun do_north_tab ()
      (command "_.LAYOUT" "N" "North View")
      (command "_.LAYOUT" "S" "North View")
      (MviewFit)
      (command "_.MSPACE")
      (command "_.UCS" "W")
      (command "_.UCS" "X" "90")
      (command "_.PLAN" "")
    )

    (defun do_east_tab ()
      (command "_.LAYOUT" "N" "East View")
      (command "_.LAYOUT" "S" "East View")
      (MviewFit)
      (command "_.MSPACE")
      (command "_.UCS" "W")
      (command "_.UCS" "X" "90")
      (command "_.UCS" "Y" "270")
      (command "_.PLAN" "")
    )

    (defun C:IV ()
      (command "_.TILEMODE" "1")
    )

    (defun C:PV ()
      (command "_.LAYOUT" "S" "Plan View")
    )

    (defun C:NV ()
      (command "_.LAYOUT" "S" "North View")
    )

    (defun C:EV ()
      (command "_.LAYOUT" "S" "East View")
    )

    ;The following code was provided by Roy Klein Gebbinck from the BricsCAD Forum

    (defun MviewFit ( / doc lst)
      (setq doc (vla-get-activedocument (vlax-get-acad-object)))
      (vla-endundomark doc) ; End open undo group.
      (vla-startundomark doc)
      (setq lst (acet-geom-view-points)) ; Points are in current UCS.
      (setvar 'cmdecho 0)
      (command "_.mview" "_non" (car lst) "_non" (cadr lst))
      (setvar 'cmdecho 1)
      (vla-endundomark doc)
      (princ)
    )
    [/code]

    It might look a bit untidy to some, but it works fine for me and I'm a happy man, thanks to Roy and Jason :-D

    cheers

    andy
  • Here is a shorter version to compete with Roy's :-)

    [code];Create an MVIEW to fit the current screen size
    (defun C:MVIEW-FIT ( / ScreenCoords)
        (acet-sysvar-set '("CMDECHO" 0 "OSMODE" 0))
        (setq ScreenCoords (acet-geom-view-points))
        (if (and (= 0 (getvar 'TILEMODE)) (= 1 (getvar 'CVPORT)))
            (command "._MVIEW" (car ScreenCoords) (cadr ScreenCoords))
            (princ "\nCan't create VPORT in Model Space")
        )
        (acet-sysvar-restore)
        (prin1)
    )[/code]

    Regards,
    Jason Bourhill

  • Here is a shorter version to compete with Roy's :-)

    ;Create an MVIEW to fit the current screen size(defun C:MVIEW-FIT ( / ScreenCoords)    (acet-sysvar-set '("CMDECHO" 0 "OSMODE" 0))    (setq ScreenCoords (acet-geom-view-points))    (if (and (= 0 (getvar 'TILEMODE)) (= 1 (getvar 'CVPORT)))        (command "._MVIEW" (car ScreenCoords) (cadr ScreenCoords))        (princ "\nCan't create VPORT in Model Space")    )    (acet-sysvar-restore)    (prin1))   


    Regards,
    Jason Bourhill


    Haha! Jason! Thanks :-D
  • You may also like to look at the LAYOUT TEMPLATE option. Assuming you don't move from machine to machine much or change the screen size, you could create a template drawing with the view tabs preset, then simply import them e.g.

    [code](command "._LAYOUT" "_TEMPLATE" "MyDrawingViews" "Plan View")
    (command "._LAYOUT" "_TEMPLATE" "MyDrawingViews" "North View")
    (command "._LAYOUT" "_TEMPLATE" "MyDrawingViews" "East View")
    (command "._LAYOUT" "_TEMPLATE" "MyDrawingViews" "Model") [/code]


    Regards,
    Jason Bourhill

  • You may also like to look at the LAYOUT TEMPLATE option. Assuming you don't move from machine to machine much or change the screen size, you could create a template drawing with the view tabs preset, then simply import them e.g.

    (command "._LAYOUT" "_TEMPLATE" "MyDrawingViews" "Plan View")(command "._LAYOUT" "_TEMPLATE" "MyDrawingViews" "North View")(command "._LAYOUT" "_TEMPLATE" "MyDrawingViews" "East View")(command "._LAYOUT" "_TEMPLATE" "MyDrawingViews" "Model")     



    Regards,
    Jason Bourhill


    Thanks again Jason, I will have a look at that...
This discussion has been closed.