home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / propage4.0 / arexx / eps_export.pdrx < prev    next >
Encoding:
Text File  |  1994-11-27  |  4.6 KB  |  161 lines

  1. /*
  2. Routine to export selected objects as EPS files. Exports only selected objects, not the whole page. It sets up a temporary page the size of the objects and prints that as an EPS file.
  3. Written by Don Cox, Nov 94 Copyright. Not Public Domain.
  4. */
  5.  
  6. /* $VER: EPS_Export.pdrx Nov 94 */
  7.  
  8. /*call open("STDERR","ram:trace","W")
  9. trace r*/
  10.  
  11. msg = PDSetup.rexx(2,0) /* load gdarexxsupport.library */
  12. units = getclip(pds_units)
  13. if msg ~= 1 then exit_msg(msg)
  14.  
  15. numeric digits 5
  16.  
  17. cr = '0a'x
  18.  
  19. epsfile = pdm_GetFilename("Select file for saving", "PDraw:")
  20. if epsfile = "" then exit_msg("No file selected")
  21.  
  22. call pdm_ShowStatus("  Analysing objects...")
  23.  
  24. /* First go through getting overall size */
  25. object = pdm_SelFirstObj()
  26. objectnumber = 1
  27. totalpoints = 0
  28.  
  29. if object = 0 then exit_msg("No objects selected")
  30. do until object = 0
  31.     if pdm_IsEllipse(object) = 1 then call pdm_EllipseToGraphic(object)
  32.     if pdm_IsText(object) = 1 then do
  33.         textobject = pdm_SelectObj(object)
  34.         call pdm_TextToGraphic()
  35.         end
  36.     if pdm_IsBezier(object)=1 then do
  37.         numpoints = pdm_GetObjOrder(object)
  38.         totalpoints = totalpoints+numpoints
  39.         VisSize = pdm_GetObjVisSize(object)
  40.         VisPos = pdm_GetObjVisPosn(object)
  41.         parse var VisSize VisWidth VisHeight
  42.         parse var VisPos Xcoord Ycoord
  43.         if objectnumber = 1 then do
  44.             smallestY = Ycoord /* pick up first Y value in file */
  45.             smallestX = Xcoord
  46.             biggestX = Xcoord
  47.             biggestY = Ycoord
  48.             end
  49.         if Ycoord>biggestY then biggestY = Ycoord
  50.         if Ycoord<smallestY then smallestY = Ycoord
  51.         if Xcoord>biggestX then biggestX = Xcoord
  52.         if Xcoord<smallestX then smallestX = Xcoord
  53.  
  54.         Ycoord = Ycoord+VisHeight /* Look at bottom right corner */
  55.         Xcoord = Xcoord+VisWidth
  56.         if Ycoord>biggestY then biggestY = Ycoord
  57.         if Ycoord<smallestY then smallestY = Ycoord
  58.         if Xcoord>biggestX then biggestX = Xcoord
  59.         if Xcoord<smallestX then smallestX = Xcoord
  60.  
  61.         end
  62.  
  63.  
  64. /* Grid routines cannot be used yet due to bug in PDraw IsGrid command
  65.     if pdm_IsGrid(object)=1 then do
  66.         numpoints = 4
  67.         totalpoints = totalpoints+numpoints
  68.         VisSize = pdm_GetObjVisSize(object)
  69.         VisPos = pdm_GetObjVisPosn(object)
  70.         parse var VisSize VisWidth VisHeight
  71.         parse var VisPos Xcoord Ycoord
  72.         if objectnumber = 1 then do
  73.             smallestY = Ycoord /* pick up first Y value in file */
  74.             smallestX = Xcoord
  75.             biggestX = Xcoord
  76.             biggestY = Ycoord
  77.             end
  78.         if Ycoord>biggestY then biggestY = Ycoord
  79.         if Ycoord<smallestY then smallestY = Ycoord
  80.         if Xcoord>biggestX then biggestX = Xcoord
  81.         if Xcoord<smallestX then smallestX = Xcoord
  82.  
  83.         Ycoord = Ycoord+VisHeight /* Look at bottom right corner */
  84.         Xcoord = Xcoord+VisWidth
  85.         if Ycoord>biggestY then biggestY = Ycoord
  86.         if Ycoord<smallestY then smallestY = Ycoord
  87.         if Xcoord>biggestX then biggestX = Xcoord
  88.         if Xcoord<smallestX then smallestX = Xcoord
  89.         end  /* of grid */
  90.  
  91. */
  92.  
  93.     object = pdm_SelNextObj(object)
  94.     objectnumber = objectnumber+1
  95.     end
  96.  
  97. if objectnumber = 1 then exit_msg("No objects selected")
  98. sizeX = (biggestX-smallestX) 
  99. sizeY = (biggestY-smallestY)
  100.  
  101. oldepsf = pdm_GetPSEPSF()
  102. call pdm_SetPSEPSF(1)
  103.  
  104. newpage = pdm_CreatePage(1,1,new)
  105. call pdm_SetPageSize(newpage,sizeX,sizeY)
  106.  
  107. num = 0
  108. object = pdm_SelFirstObj()
  109. do while object ~= 0
  110.    if ((pdm_iscompound(object) = 0) | (pdm_isfirst(object) ~= 0)) then do
  111.    num = num + 1
  112.       objects.num = object
  113.    end
  114.    object = pdm_SelNextObj(object)
  115. end
  116.  
  117. do i = 1 to num
  118.     newobject  = pdm_CloneObj(objects.i, 0, 0, 0, 0, 1, 1, 0)
  119.     call pdm_SetObjPage(newobject, newpage)
  120.     end
  121.  
  122. page = pdm_GoToPage(newpage)
  123. objs = pdm_SelectAll()
  124. call pdm_SetObjPosn(,0,0)
  125.  
  126. oldoutput = pdm_GetPSOutput()
  127. call pdm_SetPSOutput(epsfile)
  128. oldpagesize = pdm_GetPSPageSize()
  129. oldsizeX = word(oldpagesize,1)
  130. oldsizeY =word(oldpagesize,2)
  131. call pdm_SetPSPageSize(sizeX,sizeY)
  132. oldmode = pdm_GetPSPrintMode()
  133. call pdm_SetPSPrintMode(2)
  134. success = pdm_PrintPagePS(page)
  135.  
  136. done = pdm_DeleteObj()
  137. done = pdm_DeletePage(page,1)
  138.  
  139. exit_msg("Finished")
  140.  
  141. /* +++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++ */
  142.  
  143. exit_msg()
  144.  
  145. exit_msg: 
  146. do
  147.     parse arg message
  148.  
  149.     if message ~= '' then call pdm_Inform(1,message,)
  150.     call pdm_ClearStatus()
  151.     call pdm_SetUnits(units)
  152.     call pdm_AutoUpdate(1)
  153.     call pdm_SetPSEPSF(oldepsf)
  154.     call pdm_SetPSOutput(oldoutput)
  155.     call pdm_SetPSPageSize(oldsizeX,oldsizeY)
  156.     call pdm_SetPSPrintMode(oldmode)
  157.     exit
  158. end
  159.  
  160.  
  161.