如何编程旋转,镜像Revit实体(含美国AU的故事)

来源:互联网 发布:网络规划设计师 没人考 编辑:程序博客网 时间:2024/04/30 00:51


上周去美国参加AU, 一直没有时间更新博客. 回来后要分享下.

去美国AU需要分享的内容是不少,苦于时间太紧. 待我以后慢慢分享出来.

在那里见到一起工作过7年多的老同事,Jeremy Tammik, Building Coder 博客的博主. 非常高兴的事. 通过邮件的方式和电话会议的方式,我们有过很多的交流. 面对面交流是第一次.



Jeremy也在他的博客分享了与我的见面.  http://thebuildingcoder.typepad.com/blog/2014/12/the-revit-api-panel-at-autodesk-university.html



问题:


如果已经创建的柱实体,如何选择实体,并对其进行镜像, 旋转?

CBimEntity_Pole poleEnt = (CBimEntity_Pole)bimEnt;
XYZ temInterPt = new XYZ(Unit.mmToFeet(poleEnt.InterPt.X), Unit.mmToFeet(poleEnt.InterPt.Y), Unit.mmToFeet(poleEnt.InterPt.Z));
FamilyInstance column = m_ReviteDoc.Create.NewFamilyInstance(temInterPt, familySymbol, simLevelInfo.FloorLevel, StructuralType.Column);
if (null == column)
continue;

column.Mirrored = poleEnt.Mirror; //是否镜像
column.rotate(); //是否旋转
是如何进行旋转、镜像。


答:

Revit2013,14,15 对对象的进行各种操作都封装在 ElementTransformUtils 这个类中.

你可以使用CanMirrorElement 来判断是否对象可以镜像, 若可以,用 MirrorElement() 或MirrorElements() 方法进行镜像.

用RotateElement() 或RotateElements() 方法进行对象的旋转操作.

具体函数的参数信息,请参考RevitAPI.chm这个帮助文档.


镜像代码示例: (从帮助文档中摘取)

public void MirrorWall(Autodesk.Revit.DB.Document document, Wall wall){    Reference reference = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior).First();    Face face = wall.GetGeometryObjectFromReference(reference) as Face; // get one of the wall's major side faces    UV bboxMin = face.GetBoundingBox().Min;    Plane plane = new Plane(face.ComputeNormal(bboxMin), face.Evaluate(bboxMin).Add(new XYZ(10, 10, 0)));    // create a plane based on this side face with an offset of 10 in the X & Y directions    ElementTransformUtils.MirrorElement(document, wall.Id, plane);}


旋转代码示例(从帮助文档中摘取)

public void RotateColumn(Autodesk.Revit.DB.Document document, Autodesk.Revit.DB.Element element){    XYZ point1 = new XYZ(10, 20, 0);    XYZ point2 = new XYZ(10, 20, 30);    // The axis should be a bound line.    Line axis = Line.CreateBound(point1, point2);    ElementTransformUtils.RotateElement(document, element.Id, axis, Math.PI / 3.0);}




0 0
原创粉丝点击