通过 C# Com 互操作性访问 AutoCad 动态块'Block Properties Table'



我正在使用AutoCAD 2017 Professional与ObjectARX_2017_WIN_64。我正在尝试查询&使用COM互操作性在没有成功的情况下修改动态块的"块属性表"属性。该表包含名称头列和包含数据的多个行。数据是字符串和整数的类型。任何帮助都将在"做事"部分中受到欢迎。

    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
            }
        }
    }

据我所知,您只能获取或设置与表中的行索引相对应的属性值。

    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
        }
    }

相关内容

  • 没有找到相关文章

最新更新