Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Vector PAN on MVIEWs of LAYOUTs

14 REPLIES 14
SOLVED
Reply
Message 1 of 15
braudpat
1052 Views, 14 Replies

Vector PAN on MVIEWs of LAYOUTs

Hello

 

1) Please see the attached DWG ...It's a Map Drawing which has been re-projected ...

NOTE: You can see the real DWG at the center of the North Circle !

 

2) And of course the MVIEWs of ALL Layouts are EMPTY because very far !

 

3) South Circle = OLD XY - North Circle = NEW XY

And I drew a LINE ( = the move vector ) !

 

Thus I am looking for a Lisp routine which will do an kind of AutoPan (= the move vector) into :

( So a question please ! )

- either ALL MViews of ALL Layout

- or ALL MViews of ONE specific Layout

 

The move vector could be indicated by 2 CLICs with the mouse (IDEM a distance)

or on keyboard something like : @6733809.37<89.56  ( = Length and Angle of the LINE between the 2 circles)

 

And if possible, if we are into the Object Space : maybe CLIC on the LINE ( = the move vector )

 

Do you see that I mean ??

 

At the end, the MVIEWs into the LAYOUTs must show the real DWG ...

 

Thanks in advance, THE HEALTH (Stay Safe), Regards, Patrice (The Old French EE Froggy)

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


14 REPLIES 14
Message 2 of 15
ВeekeeCZ
in reply to: braudpat

Hi @braudpat 

know/tried THIS  from CAD Studio?

Message 3 of 15
braudpat
in reply to: ВeekeeCZ

Hello

 

YES Thanks I know this beautiful VLX !

 

But it can move ONLY the MVIEWs of ONE Layout !

And you must be into the Layout : OK for me ...

 

1) I would like ALSO almost the same routine for ALL Layouts ...

 

2) And (if possible) remain into the Object space and indicate the move vector

or CLIC on a LINE (which is the move vector) ...

 

<<< So my dream is >>>

Question : Which specific Layout (Acceptable for me to be into the specific Layout) or ALL Layouts (Default = ALL) : ?

Being into Object Space or into Layout Space

Please indicate the move vector (or CLIC on a LINE) : ?

 

For the move vector, with keyboard something like : 6733809.37<89.563

 

Thanks in advance, Regards, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 4 of 15
ВeekeeCZ
in reply to: braudpat

Also found this on my hdd... probably already posted somewhere...

I know... your dreams are a bit more complex... but one step after another.

 

(defun c:PanAllVPs (/ pt1 pt2 oCTAB en vp i ss vp)
  
  (if (and (setq pt1 (getpoint "\nSpecify 1st point: "))
	   (setq pt2 (getpoint "\nSpecify 2nd point: ")))
    (progn      
      (setq oCTAB (getvar 'CTAB))
      (foreach x (layoutlist)
	(setvar 'CTAB x)
	(command "_.zoom" "_E")
	(if (setq ss (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 x))))
	  (repeat (setq i (sslength ss))
	    (setq en (entget (ssname ss (setq i (1- i))))
		  vp (cdr (assoc 69 en)))
	    (if (> vp 1)
	      (progn
		(command "_.mspace")
		(setvar 'CVPORT vp)
		(command "_.PAN" pt1 pt2)))))
	(command "_.pspace"))
      (setvar 'CTAB oCTAB)))
  (princ)
)

 

Message 5 of 15
pbejse
in reply to: braudpat

 

 

(defun c:demo ( / Old_XY NEW_XY vpts in ve cvn)
      	(setq Old_XY '(596549.0 134871.0 0.0)
	     NEW_XY '(647922.0 6.86848e+06 0.0))                       
	(if
           (and  (= 0 (getvar "tilemode"))
                 (setq vpts (ssget "X" (list (cons 0 "VIEWPORT")(cons 410 (getvar 'ctab))
                                             (cons 8 "ZZZ_FENETRE"))))
                 )
	  (repeat (setq in (sslength vpts))                        	              	
                      (setq ve (ssname vpts (setq in (1- in))))
        	      (setq cvn (cdr (Assoc 69 (entget ve))))
                      (if (>  cvn 1)
                          (progn
				(command "_MSPACE")                              
				(setvar "CVPORT" cvn)
				(command "_ucs" "_World")
				(command "-pan"  "_non" NEW_XY "_non"  Old_XY)
				(command "_PSPACE")
	        		)		
	        		)
	                )
	      )
      (princ)
    )

 

 

Oops too slow 😁

Also it needs to be for all layout tab.. 🙂 anyhoo @ВeekeeCZ  posted first, no point in modfying this code then

 

 

Message 6 of 15
braudpat
in reply to: pbejse

Hello @pbejse 

 

THANKS your Lisp routine is OK when I am into a Layout ! ... which will be processed ...

with the absolute vector written into your routine ...

 

So please could you improve the routine a little bit ? 

- Ask for a vector on keyboard - something like : @6733809.37<89.563

or First Point / Second Point

No need to CLIC on a reference LINE as into my sample DWG !

- Ask for ALL Layouts (Yes/No) Default = Yes : ?

 

PLEASE don't filter the MVIEW Layer : (cons 8 "ZZZ_FENETRE")

Because MVIEW can be on any layer ! Layers UNLOCKED I presume !!

 

Thanks in advance, Regards, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 7 of 15
braudpat
in reply to: ВeekeeCZ

Hello @ВeekeeCZ 

 

SORRY but your routine is NOK for me !

 

Or I am a stupid boy !? Maybe because I am tired this evening !!

 

Have you used your Lisp routine on my test DWG with success ??

 

Thanks for your effort, Regards, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 8 of 15
pbejse
in reply to: braudpat


@braudpat wrote:

Hello @pbejse 

- Ask for ALL Layouts (Yes/No) Default = Yes : ?


How would want to proceed if the  reply is NO?

 


@braudpat wrote:

PLEASE don't filter the MVIEW Layer : (cons 8 "ZZZ_FENETRE")

Because MVIEW can be on any layer ! Layers UNLOCKED I presume !!


Understood.

 

Message 9 of 15
braudpat
in reply to: pbejse

Hello @pbejse 

 

I have an easy solution :  Must be into A Layout

-- If Process ALL Layouts (Default Option) : GO

-- If NOT, process ONLY the CURRENT Layout

 

Thanks in advance, Regards, Patrice

 

PS: I will be back into 2 hours about ... Because it's dinner time with friends ...

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 10 of 15
pbejse
in reply to: braudpat


@braudpat wrote:

I have an easy solution :  Must be into A Layout

-- If Process ALL Layouts (Default Option) : GO

-- If NOT, process ONLY the CURRENT Layout


Here you go,.. I combined @ВeekeeCZ  and my post  to adapt to your requirements.

 

(defun c:VPML ( / _TheProcess _FromTo opt oCTAB pt)
;;	pBe | Z9E3zK5E July 2020		;;;
(Defun _TheProcess ( layt p1 p2 / vpts ve cvn )
  	(command "_-Vports" "_Lock" "_Off" "_All" "")
	(if (setq vpts (ssget "X"
			      (list (cons 0 "VIEWPORT")
				    (cons 410 layt)
			      )
		       )
	    )
	  (repeat (setq in (sslength vpts))
	    (setq ve  (entget (ssname vpts (setq in (1- in))))
		  cvn (cdr (assoc 69 ve))
	    )
	    (if	(> cvn 1)
	      (progn
		(command "_MSPACE")
		(setvar "CVPORT" cvn)
		(command "_ucs" "_World")
		(command "-pan" "_non" p1 "_non" p2)
		(command "_PSPACE")		
	      )
	    )
	  )
	)
(command "_-Vports" "_Lock" "_On" "All" "")
  )
  
(defun _FromTo ( / Old_XY NEW_XY)
	(if (and
	      	(setq Old_XY (getpoint "\nSpecify Old XY: "))
		(setq NEW_XY (getpoint Old_XY "\nSpecify NEW XY: ")))
	  (list NEW_XY Old_XY ))
  )

(initget "Yes Current")
(setq opt (getkword "\nProcess ALL Layouts (Yes/Current)< Yes > : "))
(setq opt (if (null opt) "Yes" opt))
(setq oCTAB (getvar 'CTAB))
  
(cond
  (	(eq "Yes" opt)
	  (setvar 'tilemode 1)
	  (Setq pt (_FromTo))       
	      (foreach x (layoutlist)      
		(setvar 'CTAB x)
		(_TheProcess x  (Car pt) (cadr pt))
		)      
	  (setvar 'CTAB oCTAB)
		)
  (	(and (eq "Current" opt)(zerop (getvar 'Tilemode)))   		
		(setvar 'tilemode 1)
   		(Setq pt (_FromTo))
   		(setvar 'ctab oCTAB)
   	(_TheProcess oCTAB  (Car pt) (cadr pt))  
		)
  (	(alert "\n <<< Not a layout tab >>>")
		)
  )
  (princ)
  )

 HTH

 


@braudpat wrote:

PS: I will be back into 2 hours about ... Because it's dinner time with friends ...


Save some for us 😊

 

 

Message 11 of 15
ВeekeeCZ
in reply to: braudpat

Well, I did just a quick test before leaving the office and it seemed to be working. The was a trick that you need to pick the new point first, then the old. Sorry about that, @braudpat 

Anyway, @pbejse it's all yours.

Message 12 of 15
pbejse
in reply to: ВeekeeCZ


@ВeekeeCZ wrote:

Well, I did just a quick test before leaving the office and it seemed to be working. The was a trick that you need to pick the new point first, then the old. Sorry about that, @braudpat 

Anyway, @pbejse it's all yours.


FWIW it does work @ВeekeeCZ . I suspect @braudpat  point selection is not in the correct order, me thinks.

Happy weekend to you. 🙂

 

Message 13 of 15
ВeekeeCZ
in reply to: pbejse

Just one more note,  @braudpat  do some testing on large files and check all VP if there are PANed correctly.

I think, there were some issues with retrieving VP's ID... and therefore I added a ZOOM to each layout to make sure that all VPs are reloaded. Possibly zoom extents/previous. 

 

Cheers guys! Have a great weekend both!

Message 14 of 15
ronjonp
in reply to: braudpat

Here is my offering. :clinking_beer_mugs:

 

(defun c:foo (/ a c d f np o p1 p2 v sc x)
  ;; RJP » 2020-06-26
  ;; Move all viewport centers from one picked point to another
  (setvar 'tilemode 1)
  (if (and (setq p1 (getpoint "\nPick OLD center point: "))
	   (setq p2 (getpoint p1 "\nPick NEW center point: "))
	   (setq v (ssget "_X" '((0 . "VIEWPORT") (-4 . "!=") (69 . 1))))
	   (setq d (vla-get-activedocument (setq a (vlax-get-acad-object))))
      )
    (foreach vp	(mapcar 'cadr (ssnamex v))
      (cond ((vlax-write-enabled-p (setq o (vlax-ename->vla-object vp)))
	     (setvar 'ctab (cdr (assoc 410 (entget vp))))
	     (cond ((> (setq c (cdr (assoc 69 (entget vp)))) 1)
		    (and (setq f (= -1 (vlax-get o 'displaylocked))) (vlax-put o 'displaylocked 0))
		    (vlax-put d 'mspace -1)
		    (setvar 'cvport c)
		    (setq sc (vla-get-customscale o))
		    (setq np (polar (getvar 'viewctr) (angle p1 p2) (distance p1 p2)))
		    (vla-zoomcenter a (vlax-3d-point np) 1.)
		    (vla-put-customscale o sc)
		    (and f (vlax-put o 'displaylocked -1))
		    (vlax-put d 'mspace 0)
		   )
	     )
	    )
      )
    )
  )
  (princ)
)

 

 

 

 

Message 15 of 15
braudpat
in reply to: ronjonp

Hello @ВeekeeCZ , @pbejse , @ronjonp 

 

1) THANKS everybody ! ... Yours 3 routines are OK !!

 

2) THANKS for your effort & attention !

 

THE HEALTH (Stay Safe), Happy WE, Regards, Patrice (The Old French EE Froggy)

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost