欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Revit API 移动元素

程序员文章站 2022-06-10 23:27:19
...

1、Using Location 

ElementId ElementId = new ElementId(470604);
Element Element = doc.GetElement(ElementId);
LocationPoint location = Element.Location as LocationPoint;
XYZ newlocation = new XYZ(location.Point.X+10, location.Point.Y, location.Point.Z);
location.Point = newlocation;

MOVE后加偏移量! 

ElementId ElementId = new ElementId(470604);
Element Element = doc.GetElement(ElementId);
LocationPoint location = Element.Location as LocationPoint;
XYZ newlocation1 = new XYZ(10,0,0);
location.Move(newlocation1);

 

参考文献:http://help.autodesk.com/view/RVT/2014/ENU/?guid=GUID-CD3B9A83-8DBC-418E-8099-D655AB3DA010 

public void MoveColumn(Autodesk.Revit.DB.Document document, FamilyInstance column)
{
        // get the column current location
        LocationPoint columnLocation = column.Location as LocationPoint;

        XYZ oldPlace = columnLocation.Point;

        // Move the column to new location.
        XYZ newPlace = new XYZ(10, 20, 30);
        ElementTransformUtils.MoveElement(document, column.Id, newPlace);

        // now get the column's new location
        columnLocation = column.Location as LocationPoint;
        XYZ newActual = columnLocation.Point;

        string info = "Original Z location: " + oldPlace.Z + 
                        "\nNew Z location: " + newActual.Z;

        TaskDialog.Show("Revit",info);
}

 

相关标签: 移动 location