Hi Gary,
Sorry for the misunderstanding.
There is a workaround to edit existing slab's boundary.
For each Revit slab or floor, there are mapping model lines to representing the boundary of tha slab. If we change those model line's position or shape, the slab or floor's shape will be updated accordingly.
There might be many model lines in a document. How can we find the model lines that representing the slab is the key point.
Here is the solution: You need to create a tempt transaction. During this temp transaction, delete the target slab by Document.Delete() method. This method will return all the deleted elements' ids after the slab is deleted. So the slab's boundary model line can be find by iterating all the return id (get the element from those ids and compare the object type if they are ModelLine class). Finally abort this temp transaction.
After get the boundary's boundary model lines, you can change the model line's shape by changing those ModelLine object ( use this method
LocationCurve lCurve = modelLine.Location as LocationCurve;
lCurve.Curve = newcurve.
I just did a very quick test, this works.
Here is the complete command code.
For simplicity, it just move the floor by changing the curve's position..
[Autodesk.Revit.Attributes.Transaction(
Autodesk.Revit.Attributes.TransactionMode.Manual)]
publicclassChangeFloor : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute(
ExternalCommandData commandData,
refstring message,
ElementSet elements)
{
Document doc = commandData.Application.ActiveUIDocument.Document;
Autodesk.Revit.UI.Selection.Selection sel =
commandData.Application.ActiveUIDocument.Selection;
Reference ref1 = sel.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element,
"Please pick a floor to edit");
Floor f = doc.GetElement(ref1) asFloor;
Transaction transTemp = newTransaction(doc);
transTemp.Start("tempDelete");
ICollection<ElementId> ids = doc.Delete(f);
transTemp.RollBack();
List<ModelLine> mLines = newList<ModelLine>();
foreach (ElementId id in ids)
{
Element ele = doc.GetElement(id);
if (ele isModelLine)
{
mLines.Add(ele asModelLine);
}
}
Transaction trans = newTransaction(doc);
trans.Start("ChangeFloor");
//
foreach (ModelLine mline in mLines)
{
LocationCurve lCurve = mline.Location asLocationCurve;
Line c = lCurve.Curve asLine;
XYZ pt1 = c.GetEndPoint(0);
XYZ pt2 = c.GetEndPoint(1);
Transform transform = Transform.CreateTranslation(
newXYZ(1, 1, 0)); //move the line.
XYZ pt1New = transform.OfPoint(pt1);
XYZ pt2New = transform.OfPoint(pt2);
Line newLine = Line.CreateBound(pt1New, pt2New);
lCurve.Curve = newLine;
}
trans.Commit();
returnResult.Succeeded;
}
}
}
Joe Ye
Contractor
Developer Technical Services
Autodesk Developer Network