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: 

Structural Framing cut by Reference Plane

13 REPLIES 13
Reply
Message 1 of 14
scottbaldy
1371 Views, 13 Replies

Structural Framing cut by Reference Plane

I have seen a couple of posts on the forum about cutting a beam by a reference plane. None of the replies answer the question. You are redirected to one of the following:
1) InstanceVoidCutUtils - so cut with a void (not what I am looking for)
2) Extrude a cube at the reference plane and then use SolidSolidCutUtils (again not cutting with a reference plane)
3) Creating a cut within the family (again not what I am looking for)

 

The Cut Geometry tool on the toolbar does the very thing I would like to do via the API.  Is this method not available in the API?  What am I missing?

13 REPLIES 13
Message 2 of 14
jeremy_tammik
in reply to: scottbaldy

Ok, so your requirement is not answered by the existing discussions. Plus, your requirement is satisfied by the user interface Cut Geometry tool. All very interesting to know. However, you do not reveal (clearly enough for me, at least) what your requirement actually is. 

 

If I had to guess, I would guess that you wish to retrieve the intersection curves of the beam-plane cut. If so, you might try so set up a section view cutting the beam in the required location and retrieving only those curves that lie in the intersection plane. Maybe this will help?

  

  

Here are more articles on setting up a section view:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 14
scottbaldy
in reply to: jeremy_tammik

To be clear....

I want to be able to cut a structural framing element with a reference plane via the API. The Cut Geometry tool from the Revit UI does exactly that. Select the framing element, select the reference plane and the framing element is cut to the intersecting plane. The structural framing element can be moved or the framing element type can be changed and the cut is updated at the intersecting plane. Conversely the reference plane can be moved and the cut is also updated.

 

We are currently using voids to cut the structural framing element, but the void size needs to be adjusted based on the intersection angle, size and geometry of the framing member section. Basically cutting with a void gets more complicated and a reference plane would make this much simpler.

 

I want to achieve the same CutGeometry functionality via the API without using voids.

 

Also, the BooleanOperationsUtils appears to only apply to solids and cannot be applied to model elements.

Message 4 of 14
scottbaldy
in reply to: jeremy_tammik

So do you understand what I am looking for with my additional post? Is this possible without using the PostCommand -  CutGeometry?

Message 5 of 14
jeremy_tammik
in reply to: scottbaldy

Yes, BooleanOperationsUtils applies to geometry solids. You can query a BIM element for its geometry, extract the solids from that, and apply the cut operation to those.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 6 of 14
sseQTP9N
in reply to: jeremy_tammik

This does work for getting a cut geometry using BooleanOperationsUtils.CutWithHalfSpace(solid, plane), however i could not make this work on the geometry of the element itself.
As far as i know i cant just replace the element geometry by the resulting geometry of the cut operation.
Also the method BooleanOperationsUtils.CutWithHalfSpaceModifyingOriginalSolid(solid, plane) throws a null exception:
ArgumentNullException:ArgumentException
Null argument
Parameter name: solid
BooleanCut.PNG
(left: original (FamilyInstance), right: cut geomerty (as DirectShape)


Code snippet:
(i hope the few extensionmethods used are self explanatory)

            FamilyInstance element = app.ActiveUIDocument.SelectElement<FamilyInstance>();

            ReferencePlane operand = app.ActiveUIDocument.SelectElement<ReferencePlane>();

            Document.Transaction(() =>
            {
                GeometryElement geometry = element.get_Geometry(new Options());

               var solids = geometry.QuGeometry()
                .OfType<Solid>();

                IEnumerable<Solid> cuts = solids.Select(s
//BooleanOperationsUtils.CutWithHalfSpace(solid, plane)
                    => s.Cut(operand.GetPlane()));
                Document.CreateDirectShapeElement(cuts.ToList<GeometryObject>())
                .Move(new XYZ(1000, 0, 0).FromMillimeters());

//throws null exception
                //foreach (var solid in solids)
                //{
                //    if (!solid.IsElementGeometry && solid.Volume > 0)
                //    {
//BooleanOperationsUtils.CutWithHalfSpaceModifyingOriginalSolid(solid, plane)
                //        solid.CutModifyingOriginal(operand.GetPlane());
                //    }
                //}
            });



Message 7 of 14
ModPlus
in reply to: scottbaldy

If you need to cut the element at a straight angle, the following algorithm will work for you

1. Calculate through LocationCurve the parameter at the location where the cut will be made

2. Use the FamilyInstance.Split(double param) method.

3. Delete the resulting unnecessary element after the split

Message 8 of 14
gustavosanmartin
in reply to: ModPlus

The method is correct but something additional needs to be done; in my case, I still haven't managed to find the result. At the moment, I'm trying to obtain the geometries of solids resulting from dividing and applying Boolean operations.

 

whit only split

 

gustavosanmartin_0-1710953813471.png

 

final result

 

gustavosanmartin_1-1710953864614.png

 

 

Message 9 of 14

Hello,

I have managed to address the issue using an approach that, while functional, doesn't fully satisfy me. I utilize the Split method of the FamilyInstance class at the intersection point of two beams. Then, I obtain the solids of both beams and use boolean operations (BooleanOperationsUtils.ExecuteBooleanOperation) to obtain the desired solids. Subsequently, I employ the DirectShape class to display the solids in the model. In summary, the procedure is divided into the following steps:

 

  1. Selection and retrieval of beam solids: I select the relevant beams and extract their associated solids.

  2. Determination of the intersection point: I find the intersection point between the beams and use it to split one or both beams at that point.

  3. Obtaining solids after splitting: I obtain the solids resulting from the splitting of the beams.

  4. Application of boolean operations: I use boolean operations as necessary to combine, intersect, or subtract the obtained solids.

  5. Storage of geometric shapes in the DirectShape class: Finally, I store the resulting geometric shapes in instances of the DirectShape class for visualization in the model.

Message 10 of 14

I just had a chat with @sseQTP9N  of Hoermann and am in the process of raising an issue for this with the development team. To do so, I asked the brand new Meta 3 AI to summarise the discussion above (it was introduced yesterday) I simply copy-pasted the text from this thread and asked for a summary. This is the verbatim result:

  

Summary of Forum Discussion
The discussion revolves around cutting a structural framing element with a reference plane using the Revit API. The user wants to achieve the same functionality as the "Cut Geometry" tool in the Revit UI, but through the API. The goal is to cut a beam at the intersection with a reference plane, without using voids.
Key Points

 

  • The user has tried various approaches, including InstanceVoidCutUtils, Extrude, and SolidSolidCutUtils, but they don't meet the requirements.
  • Jeremy Tammik suggests using BooleanOperationsUtils, but it only works with geometry solids, not model elements.
  • sseQTP9N shares code using BooleanOperationsUtils.CutWithHalfSpace, but it doesn't work directly on the element geometry.
  • ModPlus proposes an algorithm using FamilyInstance.Split and deleting the unnecessary resulting element.
  • gustavosanmartin uses the Split method, obtains solids, applies boolean operations, and displays the result using DirectShape.

Outcome
The discussion provides different approaches to cutting a structural framing element with a reference plane, but a straightforward solution like the "Cut Geometry" tool is not available in the API. The user needs to combine various methods, like splitting, boolean operations, and DirectShape, to achieve the desired result.
  
Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 11 of 14
jeremy_tammik
in reply to: scottbaldy

Dear Scott, Sebastian, Aleksandr, Gustavo and others,

 

Thank you for your query and your extreme patience with this. Sorry it has not been escalated earlier. I asked the development team for their advice.

 

In addition, I also logged the issue REVIT-221256 [API to cut Structural Framing by Reference Plane like Cut Geometry tool] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is crucial. Our engineering team has limited resources and must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate

 

Best regards,

 

Jeremy

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 12 of 14
jeremy_tammik
in reply to: scottbaldy

The development team took a first look at the issue REVIT-221256 [API to cut Structural Framing by Reference Plane like Cut Geometry tool] and are discussing how to handle this. Meanwhile, they also point out:

  

There is another option to create a cut on Structural Families by using the Steel-Shortening feature. This shortening feature can be placed only on some supported families. I don't know if this a possible workaround or solution to what you are trying to achieve:

  

  

Best regards,

  

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 13 of 14
jeremy_tammik
in reply to: scottbaldy

Further response from the development team: 

  

This sounds similar to the long-standing request for a ‘split’ API for things like pipes, ducts, and more.

  

I don't believe there is a method to cut beams with a plane, but the next best thing is the Document.NewOpening method that creates a new opening in a beam, brace or column:

  

  

You need to need to find a host face and draw a cut profile.

  

A bit more involved but you can get the desired result.

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 14 of 14

Dear Jeremy,

I wanted to express my gratitude for your assistance and guidance during our interaction on the forum. I am pleased to inform you that, thanks to your guidance, I was able to solve the problem that led me to seek information on how to generate cuts in beams that intersect with other beams. Below, I detail the process I followed to achieve this:

  1. Beam Selection: The user initiates the process by selecting two specific beams in the Revit model through the user interface.
  2. Geometry Acquisition: Once the beams are selected, the program retrieves the associated solid geometries for each of them by querying the model's database.
  3. Intersection Calculation: Using the solid geometries of the selected beams, the program calculates the intersection point between them. This point is crucial for determining where the cut will be made.
  4. Beam Division: With the calculated intersection point, the program divides one of the beams at that point, facilitating the creation of the cut.
  5. Opening Creation: Using the Document.NewOpening method, the program creates an opening in the divided beam. This opening is generated using the intersection profile of the beams, ensuring a precise and proper fit to the geometry of the intersecting beams.
  6. Removal of Divided Beam: Once the opening is created in the divided beam, the program removes the divided beam from the model. This operation is necessary to maintain the cleanliness and consistency of the model.

In summary, the developed code allows the user to efficiently and accurately generate cuts in beams that intersect with other beams in the Revit model. This process involves beam selection, intersection calculation, beam division, opening creation, and finally, removal of the divided beam. Thanks to this solution, the design and modeling work in construction projects is facilitated.

It is important to consider the limitations of this method, such as:

  1. Dependency on Beam Intersection: The code assumes that the selected beams intersect at a specific point. If the beams do not intersect or the intersection is not clear, the calculation of the intersection point could fail.
  2. Sensitivity to Geometry: The accuracy of the intersection calculation and opening creation largely depends on the quality and complexity of the geometries of the selected beams. If the beams have complex or irregular geometries, the result may not be optimal.
  3. Limitations in Beam Division: The beam division is based on a calculated parameter (param) representing the distance from the beam's initial point to the intersection point. This may not be entirely accurate in all situations and could lead to unexpected results.
  4. Removal of Divided Portion of Beam: Currently, the code removes the final portion of the beam that is divided at the intersection point. However, this action may not always be desirable, especially if preserving the modification history is desired. Providing the user with the option to retain or remove the divided portion of the beam according to their needs would be helpful. This consideration is important for maintaining model integrity and avoiding the loss of significant data.
  5. Generation of Beam Opening: It is important to note that using the Document.NewOpening method generates an opening in the beam, allowing the user to select and edit its contour as needed. This editing capability may be favorable in some cases, as it provides flexibility to adjust the cut according to design requirements. However, it may also pose challenges if exact precision in the cut shape is required, as manual editing may not be as precise as automatic contour generation.

Thank you again for your support and guidance throughout this process.

Best regards,

 

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

Post to forums  

Autodesk Design & Make Report