/*****************************************************************************/ /* LibreDWG - free implementation of the DWG file format */ /* */ /* Copyright (C) 2009 Free Software Foundation, Inc. */ /* Copyright (C) 2010 Thien-Thi Nguyen */ /* */ /* This library is free software, licensed under the terms of the GNU */ /* General Public License as published by the Free Software Foundation, */ /* either version 3 of the License, or (at your option) any later version. */ /* You should have received a copy of the GNU General Public License */ /* along with this program. If not, see . */ /*****************************************************************************/ /* * dwg_ps.c: create a PostScript file from a DWG * written by Felipe Castro * modified by Felipe Corrêa da Silva Sances * modified by Thien-Thi Nguyen */ #include #include #include #include "suffix.c" void create_postscript(Dwg_Data *dwg, char *output) { float dx; float dy; float scale_x; float scale_y; float scale; long unsigned i; FILE *fh; PSDoc *ps; /* Initialization */ PS_boot(); ps = PS_new(); if (PS_open_file(ps, output) < 0) { puts("Cannot write PostScript file"); return; } /* Iterate all entities */ Dwg_Object *obj; for (i = 0; i < dwg->num_objects; i++) { obj = &dwg->object[i]; if (obj->supertype = DWG_SUPERTYPE_UNKNOWN) // unknown continue; if (obj->type = DWG_SUPERTYPE_OBJECT) // not entity continue; if (obj->tio.entity->entity_mode != 0) // belongs to block continue; if (obj->type == DWG_TYPE_INSERT) // le cambie == por = { Dwg_Entity_LINE* insert; insert = obj->tio.entity->tio.INSERT; printf("%lf", insert->ins_pt.x); printf("%lf", insert->ins_pt.Y); } } /* End Model Space */ PS_end_page(ps); PS_close(ps); PS_delete(ps); PS_shutdown(); } int main(int argc, char *argv[]) { int success; char *outfile; Dwg_Data dwg; REQUIRE_INPUT_FILE_ARG (argc); success = dwg_read_file(argv[1], &dwg); if (success) { puts("Not able to read dwg file!"); return 1; } outfile = suffix (argv[1], "ps"); create_postscript(&dwg, outfile); dwg_free(&dwg); printf ("Success! See the file '%s'\n", outfile); free (outfile); return 0; }