PDA

View Full Version : ViewPorts help



nicgosselin_so_hot
2012-01-11, 02:16 PM
Hi to all,

I have a DWG with about 100 pspace viewports and the problem is that the drawing in model space has moved in space on X, Y coordonates.

Does anybody haves a lisp routine or an idea to make an equal pan ( same X same Y ) in all viewports cause all viewports settings are good (scale, etc.).

Too much time and labor to do it one by one.

Thanks a lot

marko_ribar
2012-01-11, 04:29 PM
All I can think from first thought is to center them by center point... (You can calculate this point - setup one viewport and get point by (getvar 'viewctr))... Then apply this routine :



(defun c:redefXYvports ( / pt cspace ssvps i entvp vp vn )
(setvar 'tilemode 1)
(setq pt (getpoint "\nPick center point of mspace per viewport <viewctr> : "))
(if (eq pt nil) (setq pt (getvar 'viewctr)))
(foreach lay (layoutlist)
(setvar 'ctab lay)
(setq cspace (getvar "CTAB"))
(setq ssvps (ssget "_X" (list (cons 0 "VIEWPORT") (cons 410 cspace)) ))
(setq i (- (sslength ssvps) 1))
(repeat (- (sslength ssvps) 1)
(setq i (1- i))
(command "mspace")
(setq entvp (ssname ssvps i))
(setq vp (entget entvp))
(setq vn (cdr (assoc 69 vp)))
(command "mspace")
(setvar "cvport" vn)
(command "._zoom" "c" pt "")
(command "pspace")
)
)
(princ)
)


M.R.

nicgosselin_so_hot
2012-01-11, 07:04 PM
Thanks marko,

Very great code, but maybe I didn't expose correctly my problem:

All my cad work is done, my pspace layout haves a lot of viewports pointing on my drawing in model space.
Now all my drawing in model space move (X: 17.5 , Y -4.75 , Z: 0)

What can I do manually is in each viewport ( ucs , world , -pan 0,0,0 (base point) 17.5,-4.75,0 ) and now the viewport recover what i had before the move of the drawing in model space.

I did this : ^C^C_UCS;_WORLD;-PAN;0,0,0;17.5,-4.75,0;

I use it manually in each viewports but i would like a lisp to do it automaticly in all viewports because I have a lot of viewports in many drawings.

Thanks

marko_ribar
2012-01-11, 07:34 PM
(defun c:redefXYvports ( / cspace ssvps i entvp vp vn )
(foreach lay (layoutlist)
(setvar 'ctab lay)
(setq cspace (getvar "CTAB"))
(setq ssvps (ssget "_X" (list (cons 0 "VIEWPORT") (cons 410 cspace)) ))
(setq i (- (sslength ssvps) 1))
(repeat (- (sslength ssvps) 1)
(setq i (1- i))
(command "mspace")
(setq entvp (ssname ssvps i))
(setq vp (entget entvp))
(setq vn (cdr (assoc 69 vp)))
(command "mspace")
(setvar "cvport" vn)
(command "._ucs" "w")
(command "._-pan" "0,0,0" "17.5,-4.75,0")
(command "pspace")
)
)
(princ)
)


M.R.

nicgosselin_so_hot
2012-01-11, 08:14 PM
Great it works, but not all the times see the attachment

marko_ribar
2012-01-11, 10:11 PM
This should fix the problem... It runs on my comp without mistakes...



(defun c:redefXYvports ( / cspace ssvps i entvp vp vn )
(foreach lay (layoutlist)
(setvar 'ctab lay)
(setq cspace (getvar "CTAB"))
(setq ssvps (ssget "_X" (list (cons 0 "VIEWPORT") (cons 410 cspace)) ))
(repeat (setq i (sslength ssvps))
(setq i (1- i))
(setq entvp (ssname ssvps i))
(setq vp (entget entvp))
(setq vn (cdr (assoc 69 vp)))
(command "mspace")
(if (not (vl-catch-all-error-p (vl-catch-all-apply 'setvar (list 'cvport vn))))
(progn
(command "._ucs" "w")
(command "._-pan" "0,0,0" "17.5,-4.75,0")
)
)
(command "pspace")
)
)
(princ)
)


M.R.
8)

nicgosselin_so_hot
2012-01-16, 02:47 PM
great now it works perfect thanks very much!!

khanhtruongcivil399200
2013-07-11, 12:55 PM
This should fix the problem... It runs on my comp without mistakes...



(defun c:redefXYvports ( / cspace ssvps i entvp vp vn )
(foreach lay (layoutlist)
(setvar 'ctab lay)
(setq cspace (getvar "CTAB"))
(setq ssvps (ssget "_X" (list (cons 0 "VIEWPORT") (cons 410 cspace)) ))
(repeat (setq i (sslength ssvps))
(setq i (1- i))
(setq entvp (ssname ssvps i))
(setq vp (entget entvp))
(setq vn (cdr (assoc 69 vp)))
(command "mspace")
(if (not (vl-catch-all-error-p (vl-catch-all-apply 'setvar (list 'cvport vn))))
(progn
(command "._ucs" "w")
(command "._-pan" "0,0,0" "17.5,-4.75,0")
)
)
(command "pspace")
)
)
(princ)
)


M.R.
8)


Hi , Very great code , Can you upgrade it more ?
1 : Not all viewports update , so you can chose some viewport that you want update the new X,Y coordonates !
2 : X,Y coordonates can be changed , so you can give x, y value in the redefXYvports command !
thanks very much