Lisp for scrolling through open drawings

Lisp for scrolling through open drawings

Anonymous
Not applicable
758 Views
4 Replies
Message 1 of 5

Lisp for scrolling through open drawings

Anonymous
Not applicable

Has anyone a lisp to scroll through drawing files?

 

I frequently have multiple drawing open simultaneously & would like to use buttons instead of Ctrl+Tab

 

My idea is to create two buttons on a toolbar with arrows

 

I would like it to work similarly to Ctrl+Tab / Shift Ctrl+Tab

 

Maybe even a 'First' & 'Last function (I realise this would need four buttons)

0 Likes
Accepted solutions (1)
759 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

AutoCAD 2014 & 15 have drawing tabs for open drawing files.  These are pretty effecient for flipping between drawings.  Maybe someone listening here can talk more about AcadXTabs Drawing tabs application.  This is somethign that I have used since AutoCAD 2002.  I don't know if it works without a liscense.  Tony have not been around for a while. 

 

this might help.

http://forums.autodesk.com/t5/autocad-2010-2011-2012/acadxtabs-amp-tony-tanzillo/td-p/2743863

 

Matthew

0 Likes
Message 3 of 5

hmsilva
Mentor
Mentor
Accepted solution

@Anonymous wrote:

...

My idea is to create two buttons on a toolbar with arrows

I would like it to work similarly to Ctrl+Tab / Shift Ctrl+Tab

Maybe even a 'First' & 'Last function (I realise this would need four buttons)


Hi sbanister,

 

add this four (quickly written and not fully tested) functions to your acaddoc.lsp file, to ensure that are loaded in every opened dwg.

 

(vl-load-com)
(defun nextdwg (/ docs i index n)
  (or acad* (setq acad* (vlax-get-acad-object)))
  (or acdoc (setq acdoc (vla-get-activedocument acad*)))
  (or doc (setq doc (vla-get-name acdoc)))
  (setq docs (vla-get-documents acad*))
  (setq n (vla-get-count docs))
  (if (> n 1)
    (progn
      (setq i 0)
      (repeat n
        (if (= (vla-get-name (vla-item docs i)) doc)
          (setq index i)
        )
        (setq i (1+ i))
      )
      (if (<= (1+ index) (1- n))
        (vla-activate (vla-item docs (1+ index)))
        (vla-activate (vla-item docs 0))
      )
    )
  )
  (princ)
)

(defun prevdwg (/ docs i index n)
  (or acad* (setq acad* (vlax-get-acad-object)))
  (or acdoc (setq acdoc (vla-get-activedocument acad*)))
  (or doc (setq doc (vla-get-name acdoc)))
  (setq docs (vla-get-documents acad*))
  (setq n (vla-get-count docs))
  (if (> n 1)
    (progn
      (setq i 0)
      (repeat n
        (if (= (vla-get-name (vla-item docs i)) doc)
          (setq index i)
        )
        (setq i (1+ i))
      )
      (if (minusp (1- index))
        (vla-activate (vla-item docs (1- n)))
        (vla-activate (vla-item docs (1- index)))
      )
    )
  )
  (princ)
)

(defun lastdwg (/ docs n)
  (or acad* (setq acad* (vlax-get-acad-object)))
  (or acdoc (setq acdoc (vla-get-activedocument acad*)))
  (or doc (setq doc (vla-get-name acdoc)))
  (setq docs (vla-get-documents acad*))
  (setq n (vla-get-count docs))
  (if (> n 1)
    (vla-activate (vla-item docs (1- n)))
  )
  (princ)
)

(defun firstdwg (/ docs n)
  (or acad* (setq acad* (vlax-get-acad-object)))
  (or acdoc (setq acdoc (vla-get-activedocument acad*)))
  (or doc (setq doc (vla-get-name acdoc)))
  (setq docs (vla-get-documents acad*))
  (setq n (vla-get-count docs))
  (if (> n 1)
    (vla-activate (vla-item docs 0))
  )
  (princ)
)

 

and the buttons command string are

(nextdwg)

(prevdwg)

(lastdwg)

(firstdwg)

 

Hope this helps,
Henrique

EESignature

Message 4 of 5

Anonymous
Not applicable
It works very well indeed Henrique. Thank you.

Rather than alter the acaddoc file (which is hidden on my machine) I saved the lisp as Scrolldwgs.lsp & within the macro wrote:
^C^C(load "SCROLLDWGS") (nextdwg)
All the functions can be called this way
0 Likes
Message 5 of 5

hmsilva
Mentor
Mentor

You're welcome, sbanister!
Glad I could help

Henrique

EESignature

0 Likes