Author Topic: Synchronize views from drawing to drawing  (Read 1558 times)

0 Members and 1 Guest are viewing this topic.

mkweaver

  • Bull Frog
  • Posts: 352
Synchronize views from drawing to drawing
« on: April 18, 2008, 08:30:33 AM »
I am trying to write an app that will take the current paperspace display in the active drawing and duplicate this view in all other open drawings.  I've written the following code, but realized that I what I'm getting is synchronized viewport views.  Not exactly what I want:-(

Any help/suggestions are appreciated.
Code: [Select]
(defun c:SyncDrawingsView (/       dwgs dwglist    center1    direction1
   height1    thisdwg vport1     vport2     width1
   )
  ;;if we're working through a viewport, close it
  (if (and
(= 0 (getvar "tilemode"))
(< 1 (getvar "cvport"))
)
    (command "pspace")
    )
  (setq
    App (vlax-get-acad-object)
    Dwgs    (vla-get-documents App)
    ThisDwg (vla-get-activedocument App)
    DwgList (vlax-for dwg dwgs
      (setq dwglist (cons dwg dwglist))
      )
    ;;A list of open drawings excluding the active drawing
    DwgList (vl-remove-if
      (function
(lambda (d)
  (equal d thisdwg)
  )
)
      dwglist
      )
    )
  (cond
    ;;There are no other drawings open
    ((or
       (null dwglist)
       (= 0 (length dwglist))
       )
     (princ "\nThis is the only drawing open - nothing to sync")
     )
    (T
     (setq
       VPort1   (vla-get-activepviewport ThisDwg)
       Center1   (vla-get-center VPort1)
       Direction1 (vla-get-direction VPort1)
       Height1   (vla-get-height VPort1)
       Width1   (vla-get-Width VPort1)
       )
     (foreach dwg dwglist
       (setq VPort2 (vla-get-activepviewport dwg))
       (vla-put-center VPort2 Center1)
       (vla-put-direction vport2 direction1)
       (vla-put-height VPort1 height1)
       (vla-put-Width VPort1 width1)
       (vla-put-activepviewport dwg VPort2)
       )
     )
    )
  )