We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to modify the block element's attribute

Hi, I’m trying to modify the block element’s attribute of layer.

I don’t know CAD well, but I’ll explain my situation in detail.

image.png

Left side tab in image.png shows the layers in DWG file, and right side tab in image shows the attribute of block.

That logo is block.
The logo is in “TEMPLATE” layer but the layer attribute of that block is defined “title”.

So I want to change block’s layer attribute to “TEMPLATE”.

How to get or set “the block’s layer attribute”?

for (int i = 0; i < image.Entities.Length; i++)
{
    if (image.Entities[i].TypeName == CadEntityTypeName.INSERT)
    {
        CadBlockEntity block = image.BlockEntities[(image.Entities[i] as CadInsertObject).Name];
        Console.WriteLine(block.Name); // It prints out "SK_IPC", i think this is working good.
        Console.WriteLine();
        Console.WriteLine(block.EndBlockLayerName); // It prints out "0".
        Console.WriteLine();
        Console.WriteLine(block.LayerName); // It prints out "0" too.
        Console.WriteLine();
        foreach (CadBaseEntity baseEntity in block.Entities)
        {
            // It prints out "TEMPLATE", which is the layer to which this block belongs.
            // But I want "title", which is attribute of this block, to be output.
            Console.WriteLine(baseEntity.LayerName);
        }
        Console.WriteLine("----------------");
    }
}

Here is my code to get “block’s layer attribute” but it doesn’t work.

@Cad_MAster,
Hello, thank you for a detailed explanation.
I believe that the value you need is stored in the insert object:

CadInsertObject insert = (CadInsertObject)cadImage.Entities[i];
insert.LayerName = …

1 Like