Humbertogo 发表于 2006-9-29 11:13:08

给我一点时间来制定一些东西,我会发回一些入门代码。

Humbertogo 发表于 2006-9-29 12:01:29

这个C#代码应该可以让你开始。我从我的一些类似的C++代码中翻译了这个,但希望。NET大师会过来指出我可能做了什么愚蠢的事情。
using System;
using System.IO;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
namespace MetricOrImperial
{
    public class Main
    {
      public static int metricOrImperial(string fileName)
      {
            if(!File.Exists(fileName)) return -1;
            Database db = new Database(false, true);
            try
            {
                db.ReadDwgFile(fileName, System.IO.FileShare.Read, false, string.Empty);
                return db.Measurement == MeasurementValue.English ? 1 : 0;
            }
            catch (Exception e)
            {
                Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(e.ToString());
                return -1;
            }
      }
    }
}

Humbertogo 发表于 2006-9-29 12:22:50

谢谢查克·加布里埃尔

Humbertogo 发表于 2006-9-29 12:33:43

不客气。
顺便说一句,我想我把返回值弄反了(假设您想遵循MEASUREENT系统变量的约定)。它应该为English返回0,为英制返回1。

deegeecees 发表于 2006-9-29 13:54:44

autocad系统变量测量是我认为的AutoCAD方式
我为Autocad Mechanical编写了此函数
,并将尝试在C#代码中转换此函数
公共函数Mcad _ StandardIsMetric()作为布尔
Set symbb = ThisDrawing。application . GetInterfaceObject(" symbol bauto。McadSymbolBBMgr")
设置Ge = ThisDrawing。application . GetInterfaceObject(" Ge。Application")
设置stdmgr = symbb。' Set currStand = stdmgr。当前标准Mcad _ StandardIsMetric = currStand。IsMetric结束函数
页: 1 [2]
查看完整版本: ObjectDBX