home *** CD-ROM | disk | FTP | other *** search
Wrap
/* 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. Written by Don Cox, Nov 94 Copyright. Not Public Domain. */ /* $VER: EPS_Export.pdrx Nov 94 */ /*call open("STDERR","ram:trace","W") trace r*/ msg = PDSetup.rexx(2,0) /* load gdarexxsupport.library */ units = getclip(pds_units) if msg ~= 1 then exit_msg(msg) numeric digits 5 cr = '0a'x epsfile = pdm_GetFilename("Select file for saving", "PDraw:") if epsfile = "" then exit_msg("No file selected") call pdm_ShowStatus(" Analysing objects...") /* First go through getting overall size */ object = pdm_SelFirstObj() objectnumber = 1 totalpoints = 0 if object = 0 then exit_msg("No objects selected") do until object = 0 if pdm_IsEllipse(object) = 1 then call pdm_EllipseToGraphic(object) if pdm_IsText(object) = 1 then do textobject = pdm_SelectObj(object) call pdm_TextToGraphic() end if pdm_IsBezier(object)=1 then do numpoints = pdm_GetObjOrder(object) totalpoints = totalpoints+numpoints VisSize = pdm_GetObjVisSize(object) VisPos = pdm_GetObjVisPosn(object) parse var VisSize VisWidth VisHeight parse var VisPos Xcoord Ycoord if objectnumber = 1 then do smallestY = Ycoord /* pick up first Y value in file */ smallestX = Xcoord biggestX = Xcoord biggestY = Ycoord end if Ycoord>biggestY then biggestY = Ycoord if Ycoord<smallestY then smallestY = Ycoord if Xcoord>biggestX then biggestX = Xcoord if Xcoord<smallestX then smallestX = Xcoord Ycoord = Ycoord+VisHeight /* Look at bottom right corner */ Xcoord = Xcoord+VisWidth if Ycoord>biggestY then biggestY = Ycoord if Ycoord<smallestY then smallestY = Ycoord if Xcoord>biggestX then biggestX = Xcoord if Xcoord<smallestX then smallestX = Xcoord end /* Grid routines cannot be used yet due to bug in PDraw IsGrid command if pdm_IsGrid(object)=1 then do numpoints = 4 totalpoints = totalpoints+numpoints VisSize = pdm_GetObjVisSize(object) VisPos = pdm_GetObjVisPosn(object) parse var VisSize VisWidth VisHeight parse var VisPos Xcoord Ycoord if objectnumber = 1 then do smallestY = Ycoord /* pick up first Y value in file */ smallestX = Xcoord biggestX = Xcoord biggestY = Ycoord end if Ycoord>biggestY then biggestY = Ycoord if Ycoord<smallestY then smallestY = Ycoord if Xcoord>biggestX then biggestX = Xcoord if Xcoord<smallestX then smallestX = Xcoord Ycoord = Ycoord+VisHeight /* Look at bottom right corner */ Xcoord = Xcoord+VisWidth if Ycoord>biggestY then biggestY = Ycoord if Ycoord<smallestY then smallestY = Ycoord if Xcoord>biggestX then biggestX = Xcoord if Xcoord<smallestX then smallestX = Xcoord end /* of grid */ */ object = pdm_SelNextObj(object) objectnumber = objectnumber+1 end if objectnumber = 1 then exit_msg("No objects selected") sizeX = (biggestX-smallestX) sizeY = (biggestY-smallestY) oldepsf = pdm_GetPSEPSF() call pdm_SetPSEPSF(1) newpage = pdm_CreatePage(1,1,new) call pdm_SetPageSize(newpage,sizeX,sizeY) num = 0 object = pdm_SelFirstObj() do while object ~= 0 if ((pdm_iscompound(object) = 0) | (pdm_isfirst(object) ~= 0)) then do num = num + 1 objects.num = object end object = pdm_SelNextObj(object) end do i = 1 to num newobject = pdm_CloneObj(objects.i, 0, 0, 0, 0, 1, 1, 0) call pdm_SetObjPage(newobject, newpage) end page = pdm_GoToPage(newpage) objs = pdm_SelectAll() call pdm_SetObjPosn(,0,0) oldoutput = pdm_GetPSOutput() call pdm_SetPSOutput(epsfile) oldpagesize = pdm_GetPSPageSize() oldsizeX = word(oldpagesize,1) oldsizeY =word(oldpagesize,2) call pdm_SetPSPageSize(sizeX,sizeY) oldmode = pdm_GetPSPrintMode() call pdm_SetPSPrintMode(2) success = pdm_PrintPagePS(page) done = pdm_DeleteObj() done = pdm_DeletePage(page,1) exit_msg("Finished") /* +++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++ */ exit_msg() exit_msg: do parse arg message if message ~= '' then call pdm_Inform(1,message,) call pdm_ClearStatus() call pdm_SetUnits(units) call pdm_AutoUpdate(1) call pdm_SetPSEPSF(oldepsf) call pdm_SetPSOutput(oldoutput) call pdm_SetPSPageSize(oldsizeX,oldsizeY) call pdm_SetPSPrintMode(oldmode) exit end