文章标题
来源:互联网 发布:99宿舍软件 编辑:程序博客网 时间:2024/06/16 20:48
用Revit APT选取3D点
//Picking 3D points using Revit APIusing System;using System.Collections.Generic;using System.Text;using Autodesk.Revit;using Autodesk.Revit.DB;using Autodesk.Revit.UI;using Autodesk.Revit.ApplicationServices;using System.Linq;namespace Pick3DPoint{ [Autodesk.Revit.Attributes. Transaction(Autodesk.Revit.Attributes.TransactionMode .Manual)] public class Command : IExternalCommand { public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; XYZ point_in_3d; if (SetWorkPlaneAndPickObject(uidoc, out point_in_3d)) { TaskDialog.Show("3D Point Selected" , "3D point picked on the plane" + " defined by the selected face: " + "X: " + point_in_3d.X.ToString() + ", Y: " + point_in_3d.Y.ToString() + ", Z: " + point_in_3d.Z.ToString()); return Result .Succeeded; } else { message = "3D point selection failed" ; return Result .Failed; } } /// <summary> /// Return a 3D point. First, the user is prompted /// to pick a face on an element. This defines a /// work plane, on which a second point can be /// picked. /// </summary> public bool SetWorkPlaneAndPickObject( UIDocument uidoc, out XYZ point_in_3d) { point_in_3d = null; Document doc = uidoc.Document; Reference r = uidoc.Selection.PickObject( Autodesk.Revit.UI.Selection. ObjectType.Face, "Please select a planar face to define work plane" ); Element e = doc.GetElement(r.ElementId); if (null != e) { PlanarFace face = e.GetGeometryObjectFromReference(r) as PlanarFace ; GeometryElement geoEle = e.get_Geometry(new Options()); Transform transform = null ; foreach (GeometryObject gObj in geoEle) { GeometryInstance gInst = gObj as GeometryInstance; if (null != gInst) transform = gInst.Transform; } if (face != null ) { Plane plane = null ; if (null != transform) { plane = new Plane (transform.OfVector(face.Normal), transform.OfPoint(face.Origin)); } else { plane = new Plane (face.Normal, face.Origin); } Transaction t = new Transaction(doc); t.Start( "Temporarily set work plane" + " to pick point in 3D"); SketchPlane sp = SketchPlane .Create(doc,plane); uidoc.ActiveView.SketchPlane = sp; uidoc.ActiveView.ShowActiveWorkPlane(); try { point_in_3d = uidoc.Selection.PickPoint( "Please pick a point on the plane" + " defined by the selected face" ); } catch (OperationCanceledException ) { } t.RollBack(); } } return null != point_in_3d; } }}
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- Nginx负载均衡配置实例详解
- NSIS-plugins参考网址
- android单元测试报错:junit.framework.AssertionFailedError: Method "xxx" not found解决方案:
- Hadoop深入学习:解析HDFS的写文件流程
- ORA-29275 的问题
- 文章标题
- PL/SQL使用技巧
- HTTP Content-type 与 AFNetworking
- c primer plus7.12编程练习
- SQL/LINQ/Lamda
- [HDU1789]Doing Homework again[贪心]
- 使用easyBCD 安装 Win8 + Ubuntu 13.10 双系统
- java-计算任意日期所在周、月、年的第一天与最后一天
- 2015.06.23