Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cutting Elements

3 REPLIES 3
Reply
Message 1 of 4
acm
Explorer
3335 Views, 3 Replies

Cutting Elements

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.

3 REPLIES 3
Message 2 of 4
jeremytammik
in reply to: acm

Dear Acm,

Thank you for your query and nice clean sample code.

There are several different possible ways to perform Boolean operations between Revit elements.

I put together a collection of pointers to various discussions on The Building Coder for you:

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.30

The approach you are attempting using SolidSolidCutUtils within the family environment is one of the better and effective options in most cases.

However, just as you have discovered, it has certain requirements on the input solids.

Just as its name implies, the cutting solid must be a solid.

A reference line definitely does not fulfil this requirement.

You will have to create a solid somehow.

Here is one suggestion of what you could do:

Use the reference line you already have and another one perpendicular to it to define a plane, then define a large extruded cube on that plane, and subtract that from your main body.

I also noted that you submitted an ADN case for this in parallel with this forum discussion thread.

I hope this helps.

Please avoid submitting to ADN and the forum in parallel, or, if you insist, please, please, please let us know about it to help us avoid having several people researching the same issue in separate threads or cases. Thank you!

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 4
jeremytammik
in reply to: jeremytammik

Dear Acm,

Thank you again for your query.

 

I published the answer on The Building Coder:

 

http://thebuildingcoder.typepad.com/blog/2014/01/sustainably-chugging-along.html#6

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 4

Hello Jeremy,

 

is it possible to cut an adaptive Familyinstance with a plane? I want to turn a uniform tubbing-ring into a taperring by attaching a plane on one end, and then rotating it into the tubbing-ring by a fixed angle. Then cutt off the material on the other side of the plane?

 

I tried using a floor:

 

FamilyInstance fi = AdaptiveComponentInstanceUtils.CreateAdaptiveComponentInstance(doc, symbol);

Floor floor = doc.Create.NewSlab(profile, level, line, 0.1, true);

SolidSolidCutUtils.AddCutBetweenSolids(doc, fi, floor, true);

 

Exception: "The element does not meet the condition that it must be solid and must be a GenericForm, GeomCombination, or a FamilyInstance.\r\nParameter name: solidToBeCut"

 

What I don't understand is that the element for solidToBeCut, fi, is a FamilyInstance, so what is the problem?

 

 

dirk

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community