Mark
Mark

Reputation: 194

Accessing AutoCad Dynamic Block 'Block Properties Table' through C# Com Interoperability

I am using AutoCAD 2017 Professional with ObjectARX_2017_Win_64. I am attempting to query & modify the "Block Properties Table" property of a Dynamic block using COM Interoperability without success. The Table contains name headed Columns and multiple rows containing the data. The data is of type String and Integer. Any help would be welcome in the "Do Stuff" section.

    using Autodesk.AutoCAD.Interop;
    using Autodesk.AutoCAD.Interop.Common;
    using System.Runtime.InteropServices;
    .
    .
    .
    public void DrawLayout(boards board, FormAutocad frmAutoCad)
    {
        double[] insertpoint = new double[] { 0, IP_CONNECTOR_Y, 0 };
        if (AcadLinkStart(frmAutoCad))
        {
            destdwg = acadApp.ActiveDocument;
            // Get all the standard blocks from BLOCK_REF and place in destination drawing
            CopyStandardBlocksToDrawing();
            AcadBlockReference o = destdwg.ModelSpace.InsertBlock(insertpoint, "041_CHASSIS", 1.0, 1.0, 1.0, 0.0); // Ensure blocks are loaded in CopyStandardBlocksToDrawing

            Object[] attribs = o.GetAttributes() as object[];
            Object[] props = o.GetDynamicBlockProperties() as object[];
            foreach (var prop in props.OfType<AcadDynamicBlockReferenceProperty>())
            {
            if (prop.PropertyName == "My_Table")
            {
                 // Do Stuff
            }
        }
    }

Upvotes: 2

Views: 2556

Answers (1)

gileCAD
gileCAD

Reputation: 2493

As far as I know, you only can get or set the property Value which corresponds to the row index in the table.

    Object[] props = o.GetDynamicBlockProperties();
    foreach (var prop in props.OfType<AcadDynamicBlockReferenceProperty>())
    {
        if (prop.PropertyName == "My_Table")
        {
            if (prop.Value != 0)
                prop.Value = (short)0; // <- reset to the first row
        }
    }

Upvotes: 1

Related Questions