Cutting Elements

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to write a tool that will cut a beam to to a reference plane and I'm not sure if it's possible in the API with SolidSolidCutUtils because of the element type that is a beam or reference plane. Here's my code so far:
TaskDialog.Show("Step 1", "Choose an element as a reference to cut to.");
Reference eRef = m_document.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "Please reference line.");
TaskDialog.Show("Step 2", "Choose an element to cut.");
Reference eCut = m_document.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "Please pick an element.");
if (eRef != null && eRef.ElementId != ElementId.InvalidElementId && eCut != null && eCut.ElementId != ElementId.InvalidElementId)
{
CutElement(eRef, eCut, m_document, doc, activeDoc);
}
void CutElement(Reference eRef, Reference eCut, UIDocument m_document, Document doc, Document activeDoc)
{
//TaskDialog.Show("Step 2", "Here");
int CutElement = m_document.Document.GetElement(eCut).Id.IntegerValue;
int ReferenceLine = m_document.Document.GetElement(eRef).Id.IntegerValue;
Element solidToBeCut = activeDoc.GetElement(new ElementId(CutElement));
Element cuttingSolid = activeDoc.GetElement(new ElementId(ReferenceLine));
Transaction transaction = new Transaction(activeDoc);
transaction.Start("AddCutBetweenSolids(activeDoc, solidToBeCut, cuttingSolid)");
SolidSolidCutUtils.AddCutBetweenSolids(activeDoc, solidToBeCut, cuttingSolid);
transaction.Commit();
}
The problem is I get an error at AddCutBetweenSolids that the parameter solidToBeCut isn't of the right type. Is there another method that would accomplish what I'm trying to do or is there a way to fix this method to do what I want?
Thanks in advance.