Dear Mr.Urban

 

I have been using dxflib for many years to enable an application that I have
developed to export DXF files that contain mostly simple objects,  like
lines and arcs.

I have just learned about LibreCad and would like to use that to export in
DWG-format.

My problem is however that I cannot find a LibreDwg sample file that creates
a new empty DWG object, adds some layers/lines/arcs in that dwg and then
save it as a file.

I would greatly appreciate if you could provide me with a basic code sample.

 

Best regards

 

Anton Keim

 

PS

I have started with a very simple sample with the following code. It creates
a DWG file, but I can not open it in a CAD application. I get an error
message that the file is corrupt, needs recovery. Any suggestions?

 

#include "dwg.h"

#include "dwg_api.h"

 

/*-------------------------------------------------------------------------*
/

/* GLOBAL VARIABLES
*/

/*-------------------------------------------------------------------------*
/

Dwg_Data *Dwg;

Dwg_Object_BLOCK_HEADER hdr;

 

 

/*********1*********2*********3*********4*********5*********6*********7*****
*/

/*********1*********2*********3*********4*********5*********6*********7*****
*/

int plot_DWG()

{

  dwg_point_3d pnt1, pnt2;

 

  memset(&hdr, 0, sizeof(Dwg_Object_BLOCK_HEADER));

 

  Dwg = dwg_add_Document(R_2000, 0, 0);

 

  dwg_add_LAYER(Dwg, "0");

 

  pnt1 = { 0., 0., 0. };

  pnt2 = { 1000., 1000., 0. };

  

  dwg_add_LINE(&hdr, &pnt1, &pnt2);

 

 
dwg_write_file("D:\\Develop\\MVC\\Applications\\GUI\\RideSim\\MyfirstTest.dw
g", Dwg);

 

  return OK;

}

Reply via email to