Copy Layout's ViewPort Layers settings to selected Layout (each Viewport)

Copy Layout's ViewPort Layers settings to selected Layout (each Viewport)

jtm2020hyo
Collaborator Collaborator
1,929 Views
9 Replies
Message 1 of 10

Copy Layout's ViewPort Layers settings to selected Layout (each Viewport)

jtm2020hyo
Collaborator
Collaborator

Anyone know if there exist any lisp to Copy ViewPort's layer settings to Selected Layout's Viewports?

 

S78QeG

 

Something like this:

1 Activate the first Layout to change
2 double click to ViewPort
2 Thaw/ Freeze your layers (viewport)
3 Run AutoLisp routine
4 Copy the configuration to all selected Layouts

0 Likes
Accepted solutions (3)
1,930 Views
9 Replies
Replies (9)
Message 2 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution
Message 3 of 10

jtm2020hyo
Collaborator
Collaborator

Awesome lisp, How can I apply to each ViewPorts inside the select Layouts?

 

 

0 Likes
Message 4 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution

Here's the adjusted code for multiple selection.

 

(defun c:VPV (/ tempstr int smallstr vpent laylist vpss idx) ;ViewPort (V)paste
  (if (setq laylist (vl-bb-ref 'vpc_laylist))
    (progn
      (setq oldecho (getvar "cmdecho"))
      (setvar "cmdecho" 0)
      (command "_undo" "_be")
      
      (if (setq vpss (ssget '((0 . "VIEWPORT"))))
	(repeat (setq idx (sslength vpss))
	  (setq vpent (ssname vpss (setq idx (1- idx))))
	  
	  (setq tempstr "")
	  (foreach x laylist
	    (setq tempstr (strcat tempstr x ",")))
	  
	  (setq tempstr (substr tempstr 1 (- (strlen tempstr) 1)))
	  (command "vplayer" "t" "*" "s" vpent "" "")
	  (while (> (strlen tempstr) 256)
	    (setq smallstr (substr tempstr 1 256))
	    (setq int (vl-string-position (ascii ",") smallstr 0 t))
	    (setq smallstr (substr smallstr 1 int)
		  tempstr (substr tempstr (+ int 1))
		  )
	    (command "vplayer" "f" smallstr "s" vpent "" "")
	    )
	  (command "vplayer" "f" tempstr "s" vpent "" "")
	  ))
      
      (command "_undo" "_end")
      (setvar "cmdecho" oldecho)
      );progn
    );if
  (princ)
  )

 

Message 5 of 10

jtm2020hyo
Collaborator
Collaborator

Thanks lot, this work for select multiple Viewport at same Layout.

excuse me, could add an option more for select multiple Layouts? I mean, some like:

 

1 Select multiple Layouts (PaperSpaces)

1 Run c:VPCopy

2 Select the Viewport to Copy

3 Run new command c:VPC2LAYOUTS, to copy the stored list to all ViewPorts in the selected Layouts (PaperSpaces)

 

jtm2020hyo_1-1651748414128.png

 

 

0 Likes
Message 6 of 10

ronjonp
Mentor
Mentor

@jtm2020hyo wrote:

Thanks lot, this work for select multiple Viewport at same Layout.

excuse me, could add an option more for select multiple Layouts? I mean, some like:

 

1 Select multiple Layouts (PaperSpaces)

1 Run c:VPCopy

2 Select the Viewport to Copy

3 Run new command c:VPC2LAYOUTS, to copy the stored list to all ViewPorts in the selected Layouts (PaperSpaces)

 

jtm2020hyo_1-1651748414128.png

 

 


Use the last function in @ВeekeeCZ code to do this:

C:VPCOPY
C:VPPASTE
C:VPAPPLY

0 Likes
Message 7 of 10

ВeekeeCZ
Consultant
Consultant

@ronjonp wrote:

@jtm2020hyo wrote:

Thanks lot, this work for select multiple Viewport at same Layout.

excuse me, could add an option more for select multiple Layouts? I mean, some like:

 

1 Select multiple Layouts (PaperSpaces)

1 Run c:VPCopy

2 Select the Viewport to Copy

3 Run new command c:VPC2LAYOUTS, to copy the stored list to all ViewPorts in the selected Layouts (PaperSpaces)

 

jtm2020hyo_1-1651748414128.png

 

 


Use the last function in @ВeekeeCZ code to do this:

C:VPCOPY
C:VPPASTE
C:VPAPPLY


 

That's the one that I use most. But it does something else.

0 Likes
Message 8 of 10

jtm2020hyo
Collaborator
Collaborator

Any way thanks a lot, but maybe I used this routine wrong?

Could explain us a bit how use VPPASTE to multiple Layouts_Tabs? or if this is not possible?

0 Likes
Message 9 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution
(defun c:VPVAll (/ tempstr int smallstr vpent laylist e tabs oldtab oldecho vpss idx) ;ViewPort (V)paste
  
  (if (setq laylist (vl-bb-ref 'vpc_laylist))
    
    (progn
      
      (vlax-for o (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
	(setq e (vlax-vla-object->ename o))
	(if (= 1 (getpropertyvalue e "TabSelected"))
	  (setq tabs (cons (getpropertyvalue e "LayoutName") tabs))))
      
      (setq oldecho (getvar 'cmdecho))
      (setvar "cmdecho" 1)
      (setq oldtab (getvar 'ctab))
      (command "_undo" "_be")
      
      (foreach tab tabs
	(setvar 'ctab tab)
	(command "_.pspace")	
	
	(if (setq vpss (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 (getvar 'ctab)))))
	  (repeat (setq idx (sslength vpss))
	    (setq vpent (ssname vpss (setq idx (1- idx))))
	    
	    (setq tempstr "")
	    (foreach x laylist
	      (setq tempstr (strcat tempstr x ",")))
	    
	    (setq tempstr (substr tempstr 1 (- (strlen tempstr) 1)))
	    (command "vplayer" "t" "*" "s" vpent "" "")
	    (while (> (strlen tempstr) 256)
	      (setq smallstr (substr tempstr 1 256))
	      (setq int (vl-string-position (ascii ",") smallstr 0 t))
	      (setq smallstr (substr smallstr 1 int)
		    tempstr (substr tempstr (+ int 1))
		    )
	      (command "vplayer" "f" smallstr "s" vpent "" ""))
	    (command "vplayer" "f" tempstr "s" vpent "" "")
	    )))
      
      (setvar 'ctab oldtab)
      (command "_undo" "_end")
      (setvar 'cmdecho oldecho)
      );progn
    );if
  (princ)
  )
Message 10 of 10

jtm2020hyo
Collaborator
Collaborator

thanks for you last routine, this complete my work.

0 Likes