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;
}
}
}
}
谢谢查克·加布里埃尔 不客气。
顺便说一句,我想我把返回值弄反了(假设您想遵循MEASUREENT系统变量的约定)。它应该为English返回0,为英制返回1。 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]