home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 58 / af058b.adf / PV21.lha / REXX / Center.pvrx < prev    next >
Text File  |  1991-09-21  |  1KB  |  49 lines

  1. /* Center.pvrx---This macro will get the coordinates of the center of the
  2.     bounding box of all selected objects, and move those objects so
  3.     that the new coordinates for the center of the bounding box are the
  4.     CENTER OF THE PAGE.
  5. Copyright © 1989 by Taliesin, Inc.
  6. Author: Jeff Blume & Ross Cunniff
  7. Usage:  Assign to Ctrl-Key or RX tool 
  8.     The macro expects to find at least one selected object. */
  9.  
  10. address "ProVector"
  11.  
  12. options results
  13.  
  14. /* Try to get exclusive lock on project window.
  15.     If can't get lock, not polite to interrupt. */
  16. 'Lock'
  17. if rc ~= 0 then exit
  18.  
  19. /* Get coords of bounding box center */
  20. 'SelExtent' Ext
  21. if RC ~= 0 then call ERROR "No object selected!"
  22. CX = (Ext.X1 + Ext.X2) / 2
  23. CY = (Ext.Y1 + Ext.Y2) / 2
  24.  
  25. 'GetPageSize' Pdims
  26. CPX = (Pdims.X2 + Pdims.X1) / 2
  27. CPY = (Pdims.Y2 + Pdims.Y1) / 2
  28.  
  29. MX = (CPX - CX); MY = (CPY - CY)    /* Move X  Y  (distance from center) */ 
  30.  
  31. 'SelectList' Sel; SelN = Result
  32.  
  33. 'PushUndo'
  34. do i = 0 to SelN-1
  35.     'Move'  Sel.i  MX MY
  36. end
  37.  
  38. 'Repair'
  39.  
  40. ERROR:
  41.     arg ErrTxt
  42.     if RC ~= 0 | ErrTxt ~= "" then do
  43.         'GetBool ErrTxt "Cancel" "Cancel"'
  44.         end
  45.     'UnLock'
  46.     exit
  47.  
  48. /* This page size is a problem - 3,2,7,6 */
  49.