【问题标题】:Accessing AutoCad Dynamic Block 'Block Properties Table' through C# Com Interoperability通过 C# Com 互操作性访问 AutoCAD 动态块“块属性表”
【发布时间】:2017-07-20 04:20:40
【问题描述】:

我正在使用带有 ObjectARX_2017_Win_64 的 AutoCAD 2017 Professional。我正在尝试使用 COM 互操作性查询和修改动态块的“块属性表”属性,但没有成功。该表包含以名称为标题的列和包含数据的多行。数据类型为字符串和整数。 欢迎在“Do Stuff”部分提供任何帮助。

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

【问题讨论】:

    标签: c# .net com interop autocad


    【解决方案1】:

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

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

    【讨论】:

    • 感谢 gileCAD。真可惜。块属性表似乎是存储块的自定义表格数据的理想场所。看起来我必须恢复解析多行属性而不是 500 多个参数。我会留下这个帖子,以防有人能把兔子从帽子里拉出来。
    猜你喜欢
    • 2017-10-05
    • 1970-01-01
    • 1970-01-01
    • 2021-11-06
    • 2016-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多