Hozizontal and Vertical Viewport Synchronisation using "Synchronize Viewports" express tools

Hozizontal and Vertical Viewport Synchronisation using "Synchronize Viewports" express tools

louis-simon_tremblay
Explorer Explorer
1,824 Views
6 Replies
Message 1 of 7

Hozizontal and Vertical Viewport Synchronisation using "Synchronize Viewports" express tools

louis-simon_tremblay
Explorer
Explorer

Hi,

I have 0 background in autolisp or in any kind of coding, but I am pretty sure that it is fairly easy to do what I want for someone that have experience. I did made some research and had a look into the .txt vpsync file and aspace and I am confident it can be done (but not by me!)

 

Here is the situation:

 

I have a floors plan in MS that can be from 1000m2 to 20000m2 with a grid and axis bubbles on the outer perimeter. The problem is when I want to zoom on a particular area of the floor plan in PSpace I loose all view on the bubble, making it difficult to spot where we are zooming.

 

Possible solution:

 

It is easy for me to prepare a layout template where there will always be a Master viewport in the center and 4 thinner viewport on the perimeter where the axis bubble could appear. There might be other way around, but to simplify the coding I could also position the views of the perimeter viewports so that the center of the gridline bubble intersec the center X or Y of the viewport. (depending if it is the sides or top/bottom) 

 

With this in place, "all" I need is a Synchronize Viewports "vpsync" command that would now ask for 3 selections

-Master viewport

-Vertical viewports

-Horizontal viewports

and then, align the selected viewport with the master while keeping the original "center X" coordinates for lateral viewports and the original "center Y" coordinates for top/bottom viewports.

 

To simplify the coding I could also live with to different autolisp. One for the vertical and the other for the lateral. 

 

i hope someone can help me with my problem. It would be amazing!

 

 

0 Likes
1,825 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant

Post some simplified dwgs with your states before and after.

0 Likes
Message 3 of 7

louis-simon_tremblay
Explorer
Explorer

I Will try tonight! 

Thank you,

0 Likes
Message 4 of 7

louis-simon_tremblay
Explorer
Explorer

Hi,

 

Here is the simplified DWG of 1 "floor plan" composed of 9 sections. I want to zoom on the green section and keep the grid line reference. I joined  a 3 page PDF and the DWG.

 

-"COMPLETE": Complete structure to help get the bigger picture. The green lines are the centerline of the grid bubble and are there to show the preliminary manual adjustment that I can do in the perimether viewport shown in the page "Before the command" of the pdf.

 

-"BEFORE COMMAND": Its my template layout with master viewport in the center and 4 perimiter viewports. I zoomed where I wanted on the green section in the master viewport and I position approximatively the centerline of the grid bubbles on the center of each perimeter viewport without adjusting scale.

 

-"AFTER COMMAND": Once the command is completed, I want the scale to be adjust with the master viewport and then aligned with the master viewport. I can now print a plan view of a small section while still having grid reference in a simple clic.

 

A modified VPsync command would be the perfect code because its complete and can be use with different viewport shape. However, I think that I have a simpler way to do that I want that would work 90% of the time.

 

Here is what I have in mind:

 

Same first step with a master viewport in the center and 4 viewport around. The perimeter viewports must have the same center than the Master viewport in the paper space. Manually align the center of gridline bubbles with the center of view port. The alignment doesnt have to be perfect.

 

Then the command would:

-ask to select the master viewport

-ask to select the lateral viewports

-ask to select the top and bottom viewports

then

-use matchprop command to scale the 4 perimeter viewport with the master viewport 

then

-for the 2 lateral viewports do "-pan" command in Y on each viewport with the difference between the center Y of master viewport with the -center Y of lateral viewport in model space coordinates for each viewport

then

-do the samething with center X coordinater for the up and down viewports.  

 

 

 

I hope there is a solution for my problem!

 

Thank you,

0 Likes
Message 5 of 7

ВeekeeCZ
Consultant
Consultant

Try this one. Not happy about the workflow, but... you'll see. Have two versions.

 

First.

- select horizontal bands

- select vertical bands

- select master with a single click!

- select all vps

 

(defun c:SyncHV ( / h v i e l k)
  
  (princ "\nHorizontal viewports: ")
  (if (setq h (ssget '((0 . "VIEWPORT"))))
    (repeat (setq i (sslength h))
      (setq e (ssname h (setq i (1- i)))
	    l (cons (getpropertyvalue e "ViewCenter/Y") l))))

  (princ "\nVertical viewports: ")
  (if (setq v (ssget '((0 . "VIEWPORT"))))
    (repeat (setq i (sslength v))
      (setq e (ssname v (setq i (1- i)))
	    k (cons (getpropertyvalue e "ViewCenter/X") k))))

  (princ "\nSelect master vp (single pick!):")
  (c:vpsync)
  (if h
    (repeat (setq i (sslength h))
      (setq e (ssname h (setq i (1- i))))
      (setpropertyvalue e "ViewCenter/Y" (nth i l))))
  
  (if v
    (repeat (setq i (sslength v))
      (setq e (ssname v (setq i (1- i))))
      (setpropertyvalue e "ViewCenter/X" (nth i k))))
  (princ)
  )

 

Second version updated lower the thread.

 

0 Likes
Message 6 of 7

louis-simon_tremblay
Explorer
Explorer

Hi,

 

Thank you very much for your help! I will need a litle time to compare the 2 versions, but it seams like the first one is working!

 

Just to be sure, I have to do the command 4 times for the second version?

 

Thanks again, I will get back when I have done more testing!

0 Likes
Message 7 of 7

ВeekeeCZ
Consultant
Consultant

No, for the first step make a single-window selection covering the entire vp. That saves you one click - but it could be confusing... so remove :S to make it the classic select&confirm selection.

 

Edit: The layer version enhanced to make it done with the need of a single window selection of all vps. Now I do like the workflow much better.

Use vpm layer for a master vp.

 

(vl-load-com)

(defun c:VPSyncLay ( / *error* :vpsyncin)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
    (princ))
  
  (defun :vpsyncin ( / m b i e y)
    (if (and (setq s (ssget "_:L:S" '((0 . "VIEWPORT") (8 . "vpm,vph,vpv"))))
	     (setq m (ssget "_P" '((8 . "vpm"))))
	     (progn
	       (vl-cmdf "_.undo" "_be")
	       (vl-cmdf "_.group" "_explode" "vpsyncm")
	       (if (> (getvar 'cmdactive) 0) (command ""))
	       (vl-cmdf "_.group" "_explode" "vpsyncs")
	       (if (> (getvar 'cmdactive) 0) (command ""))
	       T)
	     (vl-cmdf "_.group" "_create" "vpsyncm" "" m "")
	     (sssetfirst nil s)
	     (setq b (ssget "_I" '((8 . "vph,vpv"))))
	     (vl-cmdf "_.group" "_create" "vpsyncs" "" b "")
	     )
      (repeat (setq i (sslength s))
	(setq e (ssname s (setq i (1- i)))
	      y (cdr (assoc 8 (entget e)))
	      l (cons (cond ((= "vph" y) (getpropertyvalue e "ViewCenter/Y"))
			    ((= "vpv" y) (getpropertyvalue e "ViewCenter/X")))
		      l)))))
  
  (defun :vpsyncout ( / i e y)
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i)))
	    y (cdr (assoc 8 (entget e))))
      (cond ((= "vph" y)	(setpropertyvalue e "ViewCenter/Y" (nth i l)))
	    ((= "vpv" y)	(setpropertyvalue e "ViewCenter/X" (nth i l)))))
    (setq l nil s nil))
  
  (:vpsyncin)
  (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object))
    (strcat "_.vpsync\r"
	    "_group\rvpsyncm\r"
	    "_group\rvpsyncs\r\r"
	    "_.-group\r_explode\rvpsyncm\r"
	    "_.-group\r_explode\rvpsyncs\r"
	    "(:vpsyncout)\r"
	    "_.undo\r_e\r"))
  (princ)
  )

 

0 Likes