Help with pviewport please...

Discussion in 'AutoCAD' started by Devin, Mar 5, 2004.

  1. Devin

    Devin Guest

    For the life of me I can't find out how to set the view center of a
    pviewport. I've tried the target and everything else (except direction as
    it's the 3d view direction). Any help is greatly appreciated. I'm trying
    to set a view in a pviewport from a defined view.

    Thanks,

    Devin
     
    Devin, Mar 5, 2004
    #1
  2. Devin

    Jeff Mishler Guest

    Without seeing what you are trying or have tried.....

    Center property?
     
    Jeff Mishler, Mar 5, 2004
    #2
  3. Devin

    Devin Guest

    I think the center property for a paper space viewport defines the actual
    paperspace center, doesn't it? I figured that's why they only give us a
    width and a height to set the location in paper space.

    What do you think?
     
    Devin, Mar 5, 2004
    #3
  4. Devin

    Jeff Mishler Guest

    Well, not as easy as I thought, but this will get what you want, I
    think......BTW, all of the (setq's aren't combined so I can run each one
    individually for testing. I also have a couple custom routines for
    converting from ents to objs and variants to lists that I've
    included.....

    (defun c:pview ()
    (setq vp (e->v (car (entsel))));the vport for the view
    (setq vw (vla-item (vla-get-views *doc*) "profile"));the defined view
    (setq cen (vla-get-center vw));the center of the view, 2d
    (setq cen (vl-pt->list cen));convert to a list, 2d
    (setq cen (vlax-3d-point cen));convert back to variant, 3d
    (setq lokt (vla-get-displaylocked vp))
    (if (= lokt "vlax-true")
    (vla-put-displaylocked vp :vlax-false)
    )
    (vla-display vp :vlax-true);make sure it's on
    (vla-put-mspace *doc* :vlax-true);go into mspace
    (vla-put-activepviewport *doc* vp);make this one current
    (setq cscale (vla-get-customscale vp);save scales to restore
    scale (vla-get-standardscale vp)
    )
    (vla-zoomcenter *acad* cen 1.0);zoom to center obtained from view
    (vla-put-standardscale vp scale);reset scales & lock status
    (vla-put-customscale vp cscale)
    (vla-put-displaylocked vp lokt)
    )

    (defun vl-pt->list (pnt)
    (vlax-safearray->list
    (vlax-variant-value pnt)
    )
    )

    (defun e->v (ent)
    (vlax-ename->vla-object ent)
    )

    Jeff
     
    Jeff Mishler, Mar 5, 2004
    #4
  5. Devin

    Devin Guest

    Somehow I figured it would come down to a pan or zoom :( I guess I was
    hoping for just a vla-put-value or something so I wouldn't have to activate
    ms. But hey, atleast it's a solution, and that's what really matters!

    Thanks Jeff.
     
    Devin, Mar 5, 2004
    #5
  6. Here's a little sub that I ripped out of an old project. You can do away
    with the ActiveX stuff if you want.

    ;;;Arguments - ActiveX Viewport object;
    ;;;'view' data list as returned by (tblsearch "view" viewName)
    (defun PutView (vlaObj viewData)
    (setview viewData
    (cdr (assoc 69 (entget (vlax-vla-object->ename vlaObj))))
    )
    )
     
    Bobby C. Jones, Mar 5, 2004
    #6
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.