半径注释中的水平文本。 [的Autocad]

时间:2016-02-20 22:36:28

标签: autocad cad

我打开了两个文件。一个在半径注释中使用水平文本(参见第一张图片)。第二个使用半径注释中的直线(参见第二张图片)。我找不到两个文件的设置有任何区别。如何像第一个文件一样获得第二个文件的注释?

图1: enter image description here

图2: enter image description here

1 个答案:

答案 0 :(得分:0)

对于非程序化方法,您可以将“尺寸样式”从一个图形导入另一个图形。

使用编程,只需枚举样式的所有属性并进行比较。下面是实体的代码,但您需要调整Dim Style:

[CommandMethod("compEnt")]
public static void CmdCompareEntities()
{
  Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
  ObjectId id1, id2;

  //select the entities
  PromptEntityResult per1, per2;
  per1 = ed.GetEntity("\nSelect first entity: ");
  id1 = per1.ObjectId;
  per2 = ed.GetEntity("\nSelect second entity: ");
  id2 = per2.ObjectId;

  //some error check
  if (per1.Status != PromptStatus.OK ||
    per2.Status != PromptStatus.OK) return;

  Database db =
    Application.DocumentManager.MdiActiveDocument.Database;
  using (Transaction trans =
    db.TransactionManager.StartTransaction())
  {
    //open the entities
    Entity ent1 = (Entity)trans.GetObject(id1, OpenMode.ForRead);
    Entity ent2 = (Entity)trans.GetObject(id2, OpenMode.ForRead);

    Type entType1 = ent1.GetType();
    Type entType2 = ent2.GetType();

    //the two entities should be the same type
    if (!entType1.Equals(entType2)) return;

    //get the list of properties and iterate
    System.Reflection.PropertyInfo[] props =
      entType1.GetProperties();
    foreach (System.Reflection.PropertyInfo prop in props)
    {
      try
      {
        //get both values property value
        object val1, val2;
        val1 = prop.GetValue(ent1, null);
        val2 = prop.GetValue(ent2, null);
        if (val1 != null & val2 != null)
        {
          //are equal?
          if (!(val1.Equals(val2)))
          {
            //if not, write the value
            ed.WriteMessage("\n{0} is different: {1}  |  {2}",
                prop.Name, val1.ToString(), val2.ToString());
          }
        }
      }
      catch (Autodesk.AutoCAD.Runtime.Exception ex)
      {
      }
    }
    trans.Commit();
  }
}

来源:Comparing properties of two entities