2017-03-01 90 views
1

我正在使用AutoCAD 2017 Professional與ObjectARX_2017_Win_64。我試圖查詢&使用COM Interoperability修改動態塊的「塊屬性表」屬性,但沒有成功。該表包含名稱爲Columns和包含數據的多行。數據的類型是String和Integer。 任何幫助將受到歡迎在「做東西」部分。通過C#Com互操作性訪問AutoCad動態塊'塊屬性表'

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

回答

0

據我所知,你只能得到或設置屬性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 
     } 
    } 
+0

感謝gileCAD。這太遺憾了。塊屬性表似乎是存儲自定義表格數據的理想之地。看起來我必須恢復解析一個多行屬性,而不是500個參數。我會離開這個線程以防萬一有人能把兔子從帽子裏拿出來。 – Mark