根据房间的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: |