Revit API根据房间Room创建空间Space

根据房间的Level和Location得到NewSpace()的参数Level和UV
[TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class cmdRoom : IExternalCommand
{
    
public Result Execute(ExternalCommandData commandData, ref string messages, ElementSet elements)
    {
        UIApplication uiApp 
= commandData.Application;
        Document doc 
= uiApp.ActiveUIDocument.Document;
        Selection sel 
= uiApp.ActiveUIDocument.Selection;

        Transaction ts 
= new Transaction(doc, "http://revit.5d6d.com");
        ts.Start();

        Room room 
= doc.GetElement(sel.PickObject(ObjectType.Element, "选择一个房间")) as Room;
        LocationPoint roomPoint 
= room.Location as LocationPoint;
        
//doc.Create.NewSpace(room.Level, room.PhaseCreated, new UV(roomPoint.Point.X, roomPoint.Point.Y));
        doc.Create.NewSpace(room.Level, new UV(roomPoint.Point.X, roomPoint.Point.Y));

        ts.Commit();

        
return Result.Succeeded;
    }
}
from:http://revit.5d6d.com/thread-1314-1-1.html
posted @ 2011-11-03 09:44  大气象  阅读(1983)  评论(0编辑  收藏  举报
http://www.tianqiweiqi.com