Polyline viewport

Discussion in 'AutoCAD' started by T.Willey, Sep 14, 2004.

  1. T.Willey

    T.Willey Guest

    I have a routine that works, but is not as precise as I am was hopeing for. The routine works but when it zooms to the location in model space that is supposed to be the center of the viewport, it doesn't seem to be the middle.

    Any help is appreciated, the routine is still a work in progress.
    Tim

    (defun c:polyViewPort (/ ent1 vlist vlist2 xpt1 xpt2 pt1 pt2 sc1)

    (command "_.undo" "_end")
    (command "_.undo" "_group")
    (vl-load-com)
    (prompt "\n Select point: ")
    (command "_.pline")
    (while (> (getvar "cmdactive") 0)
    (command pause)
    )
    (setq ent1 (entlast))
    (if (/= (value 70 (entget ent1)) 1)
    (progn
    (setq ent1 (subst (cons 70 1) (assoc 70 (entget ent1)) (entget ent1)))
    (entmod ent1)
    )
    )
    (setq vlist (VerticePoints (entget ent1)))
    (command "_.region" ent1 "")
    (setq cpt1 (GetX (MakeX (entlast)) 'Centroid))
    (command "_.erase" (entlast) "")
    (setq sc1 (getreal "\n Enter scale of viewport: "))
    (setvar "tilemode" 0)
    (command "_.pline"
    (mapcar 'command vlist)
    )
    (setq ent2 (entlast))
    (setq ent2 (subst (cons 70 1) (assoc 70 (entget ent2)) (entget ent2)))
    (entmod ent2)
    (setq ent2 (value -1 ent2))
    (command "_.scale" ent2 "" (car vlist) (/ 1 sc1))
    (command "_.move" ent2 "" (car vlist) pause)
    (command "_.mview" "_ob" ent2)
    (command "_.mspace")
    (command "_.zoom" "_c" cpt1 (strcat (rtos (/ 1 sc1) 2 10) "xp"))
    (command "_.pspace")
    (command "_.undo" "_end")
    (princ)
    )

    (defun VerticePoints( ent1 / n vpl)

    (setq n 0)
    (while (nth n ent1)
    (if (= (car (nth n ent1)) 10)
    (setq vpl (append vpl (list (cdr (nth n ent1)))))
    )
    (setq n (1+ n))
    )
    vpl
    )

    (defun MakeX (entname)
    (vlax-ename->vla-object entname)
    )

    (defun GetX (object prop)
    (if (vlax-property-available-p object prop)
    (vlax-get object prop)
    )
    )
     
    T.Willey, Sep 14, 2004
    #1
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.