Author Topic: Speaking of CAB's Plot Tabs routine...  (Read 3687 times)

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Speaking of CAB's Plot Tabs routine...
« Reply #15 on: June 24, 2005, 05:31:22 PM »
I love writing menucode so I can help you work any bugs you come across.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Speaking of CAB's Plot Tabs routine...
« Reply #16 on: June 24, 2005, 05:37:09 PM »
To me, menucode is more rewarding.  I can show that off better than I can any other code I write.  Granted, some code does some pretty impressive stuff, but to the non-AutoCAD user, I think menus have the biggest impact.

Which is exactly what this is for.  It's a menu that anyone in the company can use with no knowledge of AutoCAD.  The client does monthly checks of it's systems throughout the building (mostly fire protection equipment and such), and this is so Joe Schmo can walk up, click on the floor he's doing the check on, and the system he wants to check, click "Change view" and he's ready to print.  Then click "Plot current view" and he's got his hardcopy.  I'm trying to make this a 3~5 click process for them.

daron

  • Guest
Speaking of CAB's Plot Tabs routine...
« Reply #17 on: June 26, 2005, 12:14:38 AM »
You can create menu's and toolbars of any code your write: vba/lisp/etc... They'll never know the difference.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Speaking of CAB's Plot Tabs routine...
« Reply #18 on: June 26, 2005, 09:51:04 AM »
Dommy,
Take a look in PLottabs Zoom subroutine. It steps through each tab.
Here it is:
Code: [Select]
;; ---------------------------------------------------------------------------
;; Function: zoom_layouts
;; Purpose : Zoom Extents For Layout Tabs, Closes any active viewports first
;; Params  : lay_lst:   list of layout names to zoom              [CAB030805]
;; ---------------------------------------------------------------------------
(defun zoom_layouts (lay_lst / lay)
  (setq *acad*  (vlax-get-acad-object)
        *doc*   (vla-get-activedocument *acad*)
  )
  (setq lay_lst (mapcar '(lambda (x) (strcase x)) lay_lst))
  (vlax-for lay (vla-get-layouts *doc*) ; step through layouts
    (if (member (strcase (vla-get-name lay)) lay_lst)
      (progn
        (vla-put-activelayout *doc* lay) ; activate layout
        (and
           (= (vla-get-activespace *doc*) 0) ; If not in paperspace
           (= (vla-get-mspace *doc*) :vlax-true) ; in mspace viewport
           (vla-put-mspace *doc* :vlax-false) ; de-activate vp
        )
        ;; =======  Start your code here  ============
        (vla-zoomextents *acad*)
        ;; =======  End your code here ==============
      )
    )
  )
)



Another way to step through the tabs is this:
Code: [Select]
(defun c:test (/ tab)
  (foreach tab (vl-remove "Model" (layoutlist))
    (setvar "ctab" tab) ; set tab current
    (if (> (getvar "cvport") 1)
      (command ".pspace") ; close viewport
    )
    (getpoint "\nPress Enter to continue.")
  )
  (princ)
)



You will notice that the order is the created order of the layouts not the
displayed order.
This one uses the display order.
Code: [Select]
(defun c:test (/ tab)
  ;; get the tabs with the order number
 (vlax-map-collection
    (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
    '(lambda (x) (setq tab-list (cons x tab-list))))
  ;;  sort in tab order
  (setq tab-list (vl-sort tab-list '(lambda (x y)
                            (< (vla-get-taborder x) (vla-get-taborder y)))))
  ;;  make list of names into strings  remove Model space
  (setq tab-list (vl-remove "Model" (mapcar '(lambda (x)(vla-get-name x))tab-list)))
  (foreach tab tab-list
    (setvar "ctab" tab) ; set tab current
    (if (> (getvar "cvport") 1)
      (command ".pspace") ; close viewport
    )
    (getpoint "\nPress Enter to continue.")
  )
  (princ)
)


Enjoy
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Speaking of CAB's Plot Tabs routine...
« Reply #19 on: June 27, 2005, 09:26:35 AM »
Fantastic!  Thanks CAB...I'll dive in at lunch.