libredwg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libredwg] setting layer of newly created entity to existing layer


From: Maarten Vergauwen
Subject: [libredwg] setting layer of newly created entity to existing layer
Date: Sat, 31 Jul 2021 21:23:21 +0200

Dear,

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);
        Dwg_Object_BLOCK_HEADER* hdr;
        dwg_point_3d pts[4];
        pts[0].x = 100; pts[0].y = 100; pts[0].z = 100;
        pts[1].x = 300; pts[1].y = 100; pts[1].z = 100;
        pts[2].x = 100; pts[2].y = 130; pts[2].z = 100;
        pts[3].x = 200; pts[3].y = 180; pts[3].z = 100;
        lastent_t ent;
        ent.u.polyline_3d = dwg_add_POLYLINE_3D(hdr, 4, pts);
        ent.type = DWG_TYPE_POLYLINE_3D;
        int err;
        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.
Kind regards,
Maarten



reply via email to

[Prev in Thread] Current Thread [Next in Thread]