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

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

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
jtm2020hyo
799 Views, 9 Replies

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

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

9 REPLIES 9
Message 2 of 10
ВeekeeCZ
in reply to: jtm2020hyo
Message 3 of 10
jtm2020hyo
in reply to: ВeekeeCZ

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

 

 

Message 4 of 10
ВeekeeCZ
in reply to: jtm2020hyo

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
in reply to: ВeekeeCZ

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

 

 

Message 6 of 10
ronjonp
in reply to: jtm2020hyo


@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

Message 7 of 10
ВeekeeCZ
in reply to: ronjonp


@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.

Message 8 of 10
jtm2020hyo
in reply to: ВeekeeCZ

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?

Message 9 of 10
ВeekeeCZ
in reply to: jtm2020hyo

(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
in reply to: ВeekeeCZ

thanks for you last routine, this complete my work.

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

Post to forums  

Autodesk Design & Make Report

”Boost