Split Brep / User string


Using “RhinoBrepSplit”, is it possible to use user strings on a brep and retrieve these user strings on the resulting breps ?
I have made some tests, adding user string on both the brep and even on each ‘ON_Surface’ of it but after “RhinoBrepSplit” I never retreive any of those user strings on any resulting breps…

Kind regards,

Hi @fthomas,

Your observation is probably correct. Thankfully, you can just copy the user strings yourself.

bool RhinoBrepSplitEx(
  const ON_Brep& brep,
  const ON_Brep& splitter,
  double tolerance,
  ON_SimpleArray<ON_Brep*>& pieces,
  bool* bRaisedTol = nullptr
  // Get the user strings from the input Brep
  ON_ClassArray<ON_UserString> user_strings;
  const int user_string_count = brep.GetUserStrings(user_strings);

  // Split the Brep
  bool rc = RhinoBrepSplit(brep, splitter, tolerance, pieces, bRaisedTol);

  // Copy the user strings to the pieces if needed
  if (rc && user_string_count > 0)
    for (int i = 0; i < pieces.Count(); i++)
      ON_Brep* piece = pieces[i];
      if (nullptr != piece)
        piece->SetUserStrings(user_string_count, user_strings.Array(), true);

  return rc;

– Dale

Hi Dale,

Thank you for your answer.

But, in fact, what we try to do is to put some data on the brep, split this brep, and after that uses this data to find which is a part of the initial brep (with user string) and which parts have been created (without user string).

Imagine a rectangular wall : brep 1

We extrude a curve (an opening like door or window) : brep2

We split brep 1 by brep2.

The result is ok : brep1 has now an hole, brep2 has disappear, and there is a new brep in this hole which is in fact the opening.

The question is : how to make the difference between the wall and the opening now ?

We was hopping that put some user strings on the wall let us find them after the split operation… but this is not the case.

And it seems to dangerous to says that in ‘ON_SimpleArray<ON_Brep*>& pieces ’ the original brep is always at index 0, followed by the new ones


Hi @fthomas,

Many ON_Brep components have a mutable ON_U union member that you can use to store user-type data in order to track components.


Try attaching come custom data to ON_BrepFace::m_face_user and see if that info survives a split operation.

– Dale

Hi Dale,

Unfortunately our attempts are all failing.

split roof/wall by ‘uncertainty opening box’ return 2 brep(s)

  • brep #1 on 2 : pRW_BREP->m_brep_user.i=0

    • face #1 on 1 : F->m_face_user.i=99
  • brep #2 on 2 : pRW_BREP->m_brep_user.i=0

    • face #1 on 1 : F->m_face_user.i=99

When using ‘RhinoBrepSplit’ m_brep_user is propagated on all resulting Breps.

And it’s the same for values attached to each face when using ‘m_face_user’

There is now way to distinguish completely new parts from the starting ones using data, and this is a real problem for us.

Kind regards,


Hi @fthomas,

There is no difference, from a Brep topology point of view, between the two pieces. If the extrusion is solid, you could figure out which is inside the extrusion. Or, if you know there will just be a single outer piece, you could just keep track of a vertex that you know will not be on the inside and keep the piece that has that vertex.

– Dale

All the pieces that result from RhinoBrepSplit are parts of the original brep. If you are using split to remove a portion of the brep from the original you might try RhinoBrepTrim instead. In this case if you take care to orient the cutter ( by orienting the curve and the extrusion direction) you can be sure that RhinoBrepTrim will keep the correct part.

Also RhinoBrepTrim provides a optional maps of edge and face indices. For each component of the result one can find the corresponding component of the source brep.