How to setvar "Viewdir"

Discussion in 'AutoCAD' started by Adesu, Feb 11, 2005.

  1. Adesu

    Adesu Guest

    Command: (setvar "viewdir" (list -2 -3 2))
    ; error: AutoCAD variable setting rejected: "viewdir" (-2 -3 2)
     
    Adesu, Feb 11, 2005
    #1
  2. Adesu

    BillZ Guest

    Maybe because it's read only?

    VIEWDIR 0.0000,0.0000,1.0000 (read only)


    Bill
     
    BillZ, Feb 11, 2005
    #2
  3. Adesu

    SkintSubby Guest

    To change your view, you'll have to use the "dview" command with the "point" option. This sets your target point and camera position.

    kinda like this

    (defun C:views ()
    (setq echo (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (setq targetpoint (getpoint "\nPlease enter target point?"));where are you looking at?
    (if (= targetpoint nil) (*error* ""))
    (setq osmd (getvar "osmode"))
    (setvar "osmode" 0)
    (setq camerapoint (getpoint targetpoint "\nPlease enter Camera Point?")) ;where are you looking from??
    (if (= camerapoint nil) (*error* ""))
    (command "dview" "all" "" "point" targetpoint camerapoint "")
    (setvar "cmdecho" echo)
    (setvar "osmode" osmd)
    (princ)
    )

    ;error handler
    (defun *error* (msg)
    (princ msg)
    (setvar "cmdecho" echo);reset command echo
    (setvar "osmode" osmd);reset osnaps
    (princ)
    );end of error handler

    Mark G
     
    SkintSubby, Feb 11, 2005
    #3
  4. Adesu

    BillZ Guest

    If working in ActiveX:

    (defun TestLisp (/ *acad* *acaddoc* *mspace* AcVp ViewCol ViewObj)
    ;---;
    (vl-load-com)
    (setq *acad* (vlax-get-acad-object)
    *acaddoc* (vla-get-activedocument *acad*)
    *mspace* (vla-get-modelspace *acaddoc*)
    )
    ;---;
    (setq ViewCol (vla-get-views *acaddoc*))
    (setq ViewObj (vla-add ViewCol "NewView1"))
    (setq AcVp (vla-get-activeviewport *acaddoc*))
    ;---;
    (vla-put-direction ViewObj (vlax-3d-point '(-2 -3 2)))
    (vla-setview AcVp ViewObj)
    (vla-put-activeviewport *acaddoc* AcVp)
    (vla-ZoomExtents *acad*)
    ;---;
    )


    Bill
     
    BillZ, Feb 11, 2005
    #4
  5. Adesu

    Adesu Guest

    Hi BilZ ,thanks for your reply,it's ok,and I must more learn about vlax.
     
    Adesu, Feb 14, 2005
    #5
  6. Adesu

    BillZ Guest

    Hi BilZ ,thanks for your reply,it's ok,and I must more learn about vlax.<<<

    Glad to help.

    Vlax opens many new doors.

    Bill
     
    BillZ, Feb 14, 2005
    #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.