#include "dwg.h"
#include "dwg_api.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

// Create a new DWG file and add a line and a circle
int main(int argc, char *argv[])
{
    Dwg_Data *dwg = NULL;
    Dwg_Object *mspace;
  Dwg_Object_BLOCK_HEADER *hdr;

    Dwg_Version_Type version = R_2000;
    int imperial = 0;
    dwg = dwg_add_Document(version, imperial, 0);
  mspace = dwg_model_space_object (dwg);
    hdr = mspace->tio.object->tio.BLOCK_HEADER;
    dwg_point_3d start = {0.0, 0.0, 0.0};
    dwg_point_3d end = {30.0, 10.0, 0.0};
    /**
     * 
     * n 1: LINE
  Layer: 0
  Color: BYLAYER
  Line type: BYLAYER
  Line thickness: BYLAYER
  ID: 4
    from point: X=0.0000 Y=0.0000
    to point: X=30.0000 Y=10.0000
    length: 31.6228
    Angle in XY plane: 18.4349
    Inc.: X=30.0000 Y=10.0000
    
     * 
    */

    // Add a line
    dwg_add_LINE(hdr, &start, &end);
    int error;
    // Write the DWG file
    error = dwg_write_file("libredwg_simple_example_add_line_circle.dwg", dwg);
    if (error >= DWG_ERR_CRITICAL)
    {
        printf("Write error in libredwg_simple_example_add_line_circle.dwg");
    }
    else
    {
        printf("DWG file successfully written");
    }
    // Free the DWG data
    dwg_free(dwg);
    return 0;
}
//x

//gcc -o libredwg_simple_example_add_line_circle libredwg_simple_example_add_line_circle.c -I/usr/local/include/libredwg -L/usr/local/lib -lredwg -lm
//./libredwg_simple_example_add_line_circle
