|
问题:
写了个读取屏幕拾取ModelLine的得到其属性的例子,但是获取的线的长度怎么和revit中尺寸标注的值不同。
代码如下:
- [csharp] view plaincopy
- [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
- public class GetEndsPt : IExternalCommand
- {
-
- public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
- ref string message,
- ElementSet elements)
- {
- try
- {
- Document doc = commandData.Application.ActiveUIDocument.Document;
- Selection sel = commandData.Application.ActiveUIDocument.Selection;
- Reference ref1 = sel.PickObject(ObjectType.Element, "请选择一个模型线");
-
-
-
- ModelLine dbline = doc.GetElement(ref1) as ModelLine;
- Curve cure = dbline.GeometryCurve;
-
- XYZ ptStart = cure.get_EndPoint(0);
- XYZ ptEnd = cure.get_EndPoint(1);
-
- string slineinfo = "line Info: ";
- slineinfo += string.Format("\n开始点xyz:({0:F3},{1:F3},{2:F3})", ptStart.X, ptStart.Y, ptStart.Z);
- slineinfo += string.Format("\n结束点xyz:({0:F3},{1:F3},{2:F3})", ptEnd.X, ptEnd.Y, ptEnd.Z);
- slineinfo += "\n线长:" + cure.Length;
- TaskDialog.Show("Get Model Line length", slineinfo);
- }
- catch(Exception ex)
- {
- message = ex.Message;
- return Result.Failed;
- }
- return Result.Succeeded;
- }
- }
复制代码 答:
Revit API中的长度单位都是统一用英尺。而软件界面看到的单位(属性栏,尺寸标注等)都是根据模型当前的长度单位显示的。如果你的长度单位设置的是mm或者m,那么你在界面上看到的数值肯定不一样。
1 英尺 = 304.8 mm
作者:叶雄进文章来源:http://blog.csdn.net/joexiongjin/article/category/782739
|
|