Hi,
As per the comments on this blog post (http://thebuildingcoder.typepad.com/blog/2008/11/editing-a-floor-profile.html ), I'd also like to see the functionality to be able to edit an existing slab (rather than delete and create a new one). I can't see that this is available, would be great to see this enabled.
Thanks,
Jon
Solved! Go to Solution.
Solved by Joe.Ye. Go to Solution.
Dear Jon,
Yes, I fully agree.
Here is another vaguely related much more recent discussion:
http://thebuildingcoder.typepad.com/blog/2013/07/create-a-floor-with-an-opening-or-complex-boundary....
Have you looked at the SlabShapeEditor class?
Best regards,
Jeremy
Hi Jeremy,
Thanks for the reply, SlabShapeEditor seems to edit geometry out of plane, but not the perimeter curve.
It would be good if perimeter definition editing could be enabled in a future build of the API.
Cheers,
Jon
I think SlabShapeEditor should be able to edit the slab shape by chaning its perimeter curve. See the sample SlabShapeEditing in Revit SDK samples subfolder to get the full sample code.
Hi,
I also need to edit an existing slab perimeter (with the API) so we can retain the Revit unique ID.
I have looked at the API reference help, used the SDK sample project / looked into what is possible but unfortunately I cannot see how it is possible to modify the slab perimeter using the SlabShapeEditor class (or the API).
It seems that the SlabShapeEditor class mimics the UI modify - add point, add split line and modify sub elements functionality. The SlabShapeEditor class allows selected vertices or creases to be offset (elevation), as per the UI modify sub elements functionality (but nothing that allows us to edit the boundary, as is possible via the UI).
I notice that there are several posts on the API forum with people asking similar questions but no there is no definitive answer given.
I would be very grateful for any feedback on this to either confirm these findings or if possible some more detail on how we can modify the slab boundary (with the API). If it isn't possible would this functionality be added to the API in the near future?
Many thanks,
Gary Easom
Dear Gary,
Thank you for your query and associated ADN case 08835154 [Edit existing slab boundary using the API].
I am sorry to say that there is currently no API access to this functionality.
I submitted the wish list item CF-65 [Edit existing slab boundary using the API -- 08835154] on your behalf for the functionality you suggest, as this issue requires exploration and possibly a modification to our software. Please make a note of this number for future reference.
Sorry for the bad news.
Best regards,
Jeremy
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;
}
}
}
The forum has issue to parse the html of the code. So it deletes some space.
I posted the article about this solution to DevBlog.
You can get the corrent code from there.
http://adndevblog.typepad.com/aec/2013/10/change-the-boundary-of-floorsslabs.html
Please vote for this "idea" at https://forums.autodesk.com/t5/revit-ideas/api-access-to-edit-sketch-add-delete-modify-curves-of-exi...
Joe Ye‘s code works very well.
Thanks.
Sometimes Revit uses another additional model line to record the value of SpanDirectionAngle.
So, the Number of model lines of a rectangle slab maybe 5 not 4.
4 for edges and 1 for SpanDirectionAngle.
Hope this helps.
Thank you.
You may want to look at the Revit Preview (aka beta) if you are interested in new sketch-based element creation and editing via API:
Wall and Shaft Opening Sketch editing API
To join the Revit Preview email revit.preview.access@autodesk.com
Dear Oleg,
Thank you for this exciting information!
Would you like me to share this invitation on The Building Coder blog as well?
Cheers,
Jeremy
Those titles look like exciting additions to the API. If they provide stable functionality of the form noted in the titles then I would consider them to be a major step forward in API functionality (regardless of what lengths I need to go to in using them).
Currently there are things we cannot do with the API. When we have a situation where everything geometry wise done in the UI can be done in the API then that is the starting point for me, especially considering increasing Forge use etc. Those items seem like a great step forward towards that aim.
Now we just need to find out how to create and edit a scope box...
Do we have any explicit invitation letter to the preview release?
I remember seeing something like that years ago...
Are you aware of a more recent version?
Great, thank you!
Here is your invitation, reposted by The Building Coder:
https://thebuildingcoder.typepad.com/blog/2021/01/sketch-based-creation-and-editing-api-preview.html
Can't find what you're looking for? Ask the community or share your knowledge.