VP Freeze a list of layers in a viewport selection set?

VP Freeze a list of layers in a viewport selection set?

Anonymous
Not applicable
2,166 Views
2 Replies
Message 1 of 3

VP Freeze a list of layers in a viewport selection set?

Anonymous
Not applicable

I created a LISP that presents the user with a dialog allowing them to select viewports in the drawing based on several different properties (like center position, layer, etc.), it then prompts the user to specify a set of layers either from the master list or from a group filter.  I was hoping that I could then use VPLAYER to VP Freeze the selected layers in the selected viewports, but VPLAYER only works on the active layout (see command call below).  

 

(command "VPLAYER" "F" (eval lyr_str) "S" ss "" "")

 

If I wanted this to freeze each viewport in selection set ss, then I would need to get the layout of the viewport, switch to that layout, and then re-run the VPLAYER command.  This is doable, but in a 30mb drawing with 50 layouts it takes a significant amount of time.  Time I was trying to save by writing the LISP in the first place.  I have searched for other methods of accessing the VP Freeze property of a viewport but have come up empty handed.

 

Does anyone know how to VP Freeze a layer in a given viewport without the VPLAYER command?

0 Likes
Accepted solutions (1)
2,167 Views
2 Replies
Replies (2)
Message 2 of 3

Moshe-A
Mentor
Mentor
Accepted solution

@Anonymous  hi,

 

>> maybe this will help <<

 

moshe

 

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks for your help finding this moshe!  The code below (C:vpfreeze) was copied from user bob.at and the code (vpfreeze) came from _gile at the link provided in the solution.

 

(defun C:vpfreeze (/)
  (vl-load-com)
  (setq myvp (car (entsel "\nSelect viewport: ")))
  (setq myvp (vlax-ename->vla-object myvp))
  (setq mylay (getstring "\nEnter layer name: "))
  (vpfreeze myvp mylay)
)

(defun vpfreeze	(vp lay / typ val)
  (vla-getXdata vp "ACAD" 'typ 'val)
  (setq	typ (reverse
	      (cons
		1002
		(cons 1002
		      (cons 1003 (cddr (reverse (vlax-safearray->list typ))))
		)
	      )
	    )
	val (reverse
	      (cons (vlax-make-variant "}")
		    (cons (vlax-make-variant "}")
			  (cons	(vlax-make-variant lay)
				(cddr (reverse (vlax-safearray->list val)))
			  )
		    )
	      )
	    )
  )
  (vla-setXData
    vp
    (vlax-safearray-fill
      (vlax-make-safearray
	vlax-vbInteger
	(cons 0 (1- (length typ)))
      )
      typ
    )
    (vlax-safearray-fill
      (vlax-make-safearray
	vlax-vbVariant
	(cons 0 (1- (length val)))
      )
      val
    )
  )
  ;; this is needed to display the change
  (vla-display vp :vlax-false)
  (vla-display vp :vlax-true)
)


 

0 Likes