I'm trying to use libredwg to add objects to an existing DWG file.
I can read the file, check the contents and add objects (e.g. a polygon_3d) just fine. What eludes me is how to set the layer of such an added object.
I can iterate through the list of existing layers and (for example) print out their names. I can't, however, seem to find how to set the layer of a new object to one of these existing layers. I've tried dwg_dynapi_entity_set_value and also setting the polyline_3d->parent->layer directly but to no avail.
Example of the former: There is a layer with the name "GVL1_3D". I create a polyline and then try to set the layer:
Dwg_Object* mspace = dwg_model_space_object(&dwg);
pts.x = 100; pts.y = 100; pts.z = 100;
pts.x = 300; pts.y = 100; pts.z = 100;
pts.x = 100; pts.y = 130; pts.z = 100;
pts.x = 200; pts.y = 180; pts.z = 100;
ent.u.polyline_3d = dwg_add_POLYLINE_3D(hdr, 4, pts);
ent.type = DWG_TYPE_POLYLINE_3D;
err = dwg_dynapi_entity_set_value(ent.u.polyline_3d, "LAYER", "layer", "GVL1_3D", 1);
The err is 0 but the layer is not set correctly.
Might you share some example code on how to do this seemingly simple operation? I would be much obliged.
Thank you very much.