这段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;
- }
- }
- }
- }
|