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;
}
}
}
}
谢谢Chuck Gabriel 你';欢迎再次光临
顺便说一句,我想返回值是倒过来的(假设你想遵循测量系统变量的约定) ;它应该为英语返回0,为英制返回1。 AutoCAD系统变量测量;是我认为的autocad方式;我写的Autocad Mechanical;此函数和;将尝试将C代码中的此函数转换为布尔函数Mcad\u standarismetric(),设置symbb=ThisDrawing.Application.GetInterfaceObject(";symbauto.McadSymbolBBMgr";)
设置Ge=ThisDrawing.Application.GetInterfaceObject(“Ge.Application”)
设置stdmgr=symbb。标准管理器------------------------------------------------------------
Set currStand=stdmgr。当前标准;Mcad_StandardIsMetric=当前状态。IsMetric端函数
页:
1
[2]