Author Topic: Moving objects in viewports  (Read 3664 times)

0 Members and 1 Guest are viewing this topic.

42

  • Bull Frog
  • Posts: 483
Moving objects in viewports
« on: January 05, 2006, 05:19:55 AM »
We have a number of drawings, 50 or so that have single viewporst on each. The prioblem is that the modle was created with the wrong base point. Once the drawing is moved to its correct 0,0 point the views from paper space are now incorrect. It was only a few drawings it would not be a problem. Do any of you have or can I steal a lisp that will open a viewport and pan the view so that the modle is visable again. The pan will be the same for every drawing.
Alastair Mallett Autodesk Certified Professional
Technical Director
Hunters South Architects

42

  • Bull Frog
  • Posts: 483
Re: Moving objects in viewports
« Reply #1 on: January 05, 2006, 05:46:41 AM »
I have written a macro button that will pan the drawing within a viewport

^C^C_mspace -pan;0,0;5000,5000;_.pspace qsave
« Last Edit: January 05, 2006, 06:04:45 AM by 42 »
Alastair Mallett Autodesk Certified Professional
Technical Director
Hunters South Architects

Amsterdammed

  • Guest
Re: Moving objects in viewports
« Reply #2 on: January 05, 2006, 06:20:21 AM »
since have a macro already, run a script. There are free scriptmakers on the web.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Moving objects in viewports
« Reply #3 on: January 05, 2006, 09:20:00 AM »
Yes the script is an easy way to go.
I have a lisp Tim posted called BScript but I can't find the link to where I got it.
Perhaps Tim will post it.
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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Moving objects in viewports
« Reply #4 on: January 05, 2006, 11:14:33 AM »
Perhaps Tim will post it.
Sure CAB.
Code: [Select]
(defun BScript (Routines / Opt DirPath DiaLoad DwgLIst tmpList Tog1 ScrFile Opened FullPath SvOpt
                           oldSdi oldLisp oldcmd oldFile flag)
; Writes a script to run multiple routines on a selection of drawings.
; If you want the drawing saved, add to routines area.
; use like (BScript '("pua" "UpdNum" "_.qsave"))
; Sub-Routines 'Directory-dia


(setq oldFile (getvar "filedia"))
(setq oldcmd (getvar "cmddia"))
(if (setq DirPath (Directory-dia "Select directory to batch process drawings."))
 (progn
  (setvar "filedia" 0)
  (setvar "cmddia" 0)
  (setq DiaLoad (load_dialog "CloseDwg.dcl"))
  (if (not (new_dialog "MultiSelect" DiaLoad))
   (exit)
  )
  (setq DwgList (vl-directory-files DirPath "*.dwg" 1))
  (setq DwgList (vl-sort DwgList '<))
  (set_tile "text1" "Select toggle to do all drawings.")
  (start_list "listbox" 3)
  (mapcar 'add_list DwgList)
  (end_list)
  (action_tile "accept"
  "(progn
   (setq tmpList (get_tile \"listbox\"))
   (setq Tog1 (get_tile \"toggle1\"))
   (done_dialog 1)
  )"
  )
  (action_tile "cancel" "(done_dialog 0)")
  (if (= (start_dialog) 1)
   (progn
    (if (= Tog1 "0")
     (setq tmpList (read (strcat "(" tmpList ")")))
     (repeat (length DwgList)
      (if (not cnt1)
       (setq cnt1 0)
       (setq cnt1 (1+ cnt1))
      )
      (setq tmpList (cons cnt1 tmpList))
     )
    )
    (setq ScrFile "C:/Custom/tmpScript.scr")
    (setq Opened (open ScrFile "W"))
    (foreach Num tmpList
     (setq FullPath (strcat DirPath (nth Num DwgList)))
     (write-line "_.open" Opened)
     (write-line (strcat "\"" FullPath "\"") Opened)
     (foreach Routine Routines
      (write-line Routine Opened)
     )
     (write-line "_.close" Opened)
    )
    (write-line "setvar" Opened)
    (write-line "filedia" Opened)
    (write-line (itoa oldFile) Opened)
    (write-line "setvar" Opened)
    (write-line "cmddia" Opened)
    (write-line (itoa oldcmd) Opened)
    (write-line "\(alert \"Done!!\"\)" Opened)
    (close Opened)
    (command "_.script" ScrFile)
   )
  )
 )
)
(princ)
)
;-------------------------------------------------
(defun Directory-Dia ( Message / sh folder folderobject result)
;; By Tony Tanzillo
;; Modified by Tim Willey

  (vl-load-com)
  (setq sh
     (vla-getInterfaceObject
        (vlax-get-acad-object)
        "Shell.Application"
     )
  )


  (setq folder
     (vlax-invoke-method
         sh
         'BrowseForFolder
         (vla-get-HWND (vlax-get-Acad-Object))
         Message
         0
      )
  )
  (vlax-release-object sh)


  (if folder
     (progn
        (setq folderobject
           (vlax-get-property folder 'Self)
        )
        (setq result
           (vlax-get-property FolderObject 'Path)
        )
        (vlax-release-object folder)
        (vlax-release-object FolderObject)
        (if (/= (substr result (strlen result)) "\\")
          (setq result (strcat result "\\"))
          result
        )
     )
  )
)

I think I got everything.  If not let me know, and I will post it.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.