PellaCAD Posted August 12, 2009 Posted August 12, 2009 I've got an interesting project...(this is VB.NET)... I need to move through each viewport on each layout tab in a drawing, doing a zoom-extents in each one. I know it will entail a couple of loops, but I keep getting hung up on moving through all the viewports. Here's some code... **************************************** For Each Item In Me.lbSelectAnAutoCADLayout.SelectedItems objAcad.ActiveDocument.ActiveLayout = objAcad.ActiveDocument.Layouts.Item(Item) OriginalSpace = objAcad.ActiveDocument.ActiveSpace objAcad.ActiveDocument.SendCommand("pspace" & vbCr) objAcad.ActiveDocument.SendCommand("zoom extents ") objAcad.ActiveDocument.SendCommand("mspace" & vbCr) objAcad.ActiveDocument.SendCommand("zoom extents ") objAcad.ActiveDocument.ActiveSpace = OriginalSpace Next **************************************** Eventually I'll need to find and activate a specific viewport on a layout (based on viewport width). But for now, just moving through each viewport on each tab in a drawing will be sufficient. Thanks in advance for your expert help! Go CADTutor! Quote
VVA Posted August 12, 2009 Posted August 12, 2009 Function in lisp (defun vpactivate ( width / ss avp) ;;; width [real] - viewport width for activate ;;; Usage ;;; (VPACTIVATE 199) ;;; Activate VIEWPORT with width 199 ;;; Return number (for CVPORT command) VIEWPORT in layout or nil (vl-load-com) (if (setq SS (ssget "_X" (list '(0 . "VIEWPORT") '(-4 . "/=") '(68 . 1)(cons 410 (getvar "ctab"))))) (progn (foreach vp (vl-remove-if (function listp) (mapcar (function cadr) (ssnamex ss))) (if (equal (cdr(assoc 40 ;_Width code. Height code - 41 (entget vp) ) ) width 1e-6 ) (progn (setq avp (cdr(assoc 68 (entget vp)))) (command "_MSPACE" "_CVPORT" avp "_PSPACE") ) ) ) ) ) avp ) Load this functions and use objAcad.ActiveDocument.SendCommand("(VPACTIVATE 199)" & vbCr) 199 - width specific viewport Quote
PellaCAD Posted August 12, 2009 Author Posted August 12, 2009 Thanks VVA!! Well done! (I think I can use this as a temporary solution.) I still need a VB dot NET solution... (Thanks again VVA...your LISP solution is clean and elegant...and it works!) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.