Bypass filtering of invalid breps?

I have a collection of polysurfaces in Rhino that I am processing and a few of them are bad objects (i.e. invalid). For various reasons, I do not want to fix the objects in Rhino immediately.

I can do a number of simple operations with them via Python scripts in GH - i.e. move, rotate etc. - and they pass through, however when I want to transform them via the GH native Transform component, it filters the invalid breps out and replaces them with Nulls. Valid breps work perfectly.

(The transforms are coming from OpenNest and they are valid, as they are generated on a parallel list of 2D objects which are all valid)

Is there no way to bypass this behavior and have it transform the invalid breps as well?

I am going to try writing a custom Python transform component and see if that helps at all*, but I thought I would ask here.

*And the answer is… Yes.

And another case - the CustomPreview component also filters out invalid objects so it doesn’t work correctly on the output of my custom Transform component. The standard basic GH preview works fine.

1 Like

Since you are familiar with coding check your Brep List as follows (that’s C#, mind):

BTW: In RC there’s some other valid related Methods available as well.

Yes, I did create my own dispatch component:

However invalid objects still make the CustomPreview component fail to display them. Oddly enough the normal GH preview has no problem with them. There are lots of other components which will also likely fail to process these objects.

I understand this is perhaps justified in order to keep bad objects from cascading through a complex system, but in my case it doesn’t matter.

Hey Helvetosaur,

Getting transformed result rather than null is great, but I’m wondering what are the benefits of keeping an invalid BREP in the pipeline. Perhaps there is a ‘combine and clean’ that fixes them like for invalid meshes?

Yes, it would be preferable to fix them first. In my case they are getting nested and then meshed for 3D printing, the meshing process may still work on the invalid breps without having to fix them first.

Fixing invalid breps - generally objects which have bad trims, invalid face loops etc. - is typically a lot more complicated than fixing bad meshes, and I don’t know of any automatic way to do this.

1 Like

I see! Thanks for clarifying!

And in the end, it doesn’t matter… I wrote my own script for transforming objects which works on invalid breps as well, but unfortunately, it is impossible to bake them out of Grasshopper with normal Bake, and I haven’t found a RhinoCommon method to allow me to script adding the invalid breps to the document…

Back to square one.

can you upload a gh file with one invalid brep internalized? this is interesting and would like a shot at it

Here you go… Have at it.

InvalidBakeTest.gh (188.5 KB)

It works for this one. Flexibility, Parakeet.

you can natively deconstruct and bake the faces. you’ll have to manually rejoin them, but a helping feature is the “group” option in the bake dialogue

you’ll also find the invalid surface in the list on the right. you can definitely write a a function that culls the invalid element , joins the rest, and caps the brep

in this particular case, isolating the invalid surface and rebuilding it from edges yields a valid surface

Hmm, interesting, I wasn’t aware that these plug-ins could manage that. I tried Flexibility and it fixed 7 of the 11 bad objects I had in this file - not bad. The Package manager didn’t get me the latest Parakeet, the version it installed (0.941) didn’t fix any of them, but there was a message that it was outdated. I downloaded and installed the latest (0.97) and it also fixed 7 out of the 11 - the same ones.

With my own personal routines - which basically involves Explode, find the bad surfaces, use a custom Python script to untrim and re-trim them then rejoin, I was able to fix all of them… One object required running that twice - have to figure out why, most likely the first run fixed the trim on the bad surface, and the next one the trims on the surrounding surfaces.

So maybe I will take this combination of tools which currently run directly in Rhino and put them together into a script that runs inside GH.

The point of this thread was that I would like to at least be able to have a preview on the invalid breps with the standard GH components, as well as having the scripted possibility to add them to the document without the need to fix them. At least an optional argument in Rhino.DocObjects.Tables.ObjectTable.AddBrep() method to allow invalid objects to be added - like the current ...AddMesh() class does.

Note also that these are relatively easy examples because the surfaces are primarily planar. Once the objects start to have curved faces, it often becomes a lot harder to fix.

Thanks to all for testing and suggestions!

2 Likes

well, a janky solution is to explode the brep and preview the face list, as i mentioned earlier.

this can be done if you write a script that sorts the invalid faces into a separate list and joins the valid ones. you get two outputs, the list of joined breps, and the list of invalid faces

//something like this meta code
validBrepList = []
invalidFaceList = []
validFaceList = []

if inputBrep is valid:
   validBrepList = inputBrep
   return

else:
   faces = getFaces(inputBrep)
   for each face in faces:
       if isvalid(face):
          validFaceList.add(face);
       else:
          invalidFaceList.add(face):

    validBrepList = joinBrep(validFaceList)
    return

Well, given the various limitations concerning invalid objects that the current iteration of GH has - brought to light by this thread and others - I am now going to concentrate on my routines for fixing the objects first.

1 Like