Trim function not trimming properly

Is there any reason why trim would give this result? I checked both prior and they are both manifolds so I really am stumped here. A look inside shows that it doesn’t go all the way through the solid so there shouldn’t be any issues there.

group to trim with

Groups to be trimmed

Result of trimming

Proof all groups are manifolds

Showing one individual trim

What size are the two objects ?
Tiny geometry will not work properly as SketchUp assumes points within 1/1000" are coincident, that edge is not created in the operation and the associated face is thereby missed too…

Can you take the two objects and manually do a ‘trim’ ?
If so then there’s something wrong in your code…
You only prove their solidity to us before you start.
The ‘trim’ needs two solids to work on…
Just select the two and try that - your convolutions make debugging harder.
e.g. your ‘groups’ contains deleted groups ! so group[0] is OK but group[1] no longer exists - although oddly your code reports it as a solid ! but the trim will fail as the second group is invalid !
Do a simple test first…

I’ll repeat some suggestions I think I made on one of your other topics:

  • your code needs to test return values from anything that can fail before continuing on with more operations. Often the consequence of a bad value isn’t felt until much later.
  • you need to learn how to debug your own code better. Simply run and see what happens is a gamble. Fine if it works, but offering no insight when it fails.

The most primitive yet an effective way to debug is to sprinkle puts statements through the code that report the values of things and watch the Ruby Console to see where things go awry. You can remove them or comment them out when the code seems to be working.

A more sophisticated way is to attach a suitable external debugger via SketchUp’s debugging interface. Going that route involves a much more elaborate setup than the simple puts technique, and requires technical understanding of debuggers in general. But it also avoids the need to guess in advance where the problem lies (to know where and what to report via puts).

My code is 800 lines long so it’s not really practical to include it. I tried the trim function with the two models not in code as well.
You’re correct, I didn’t know there was a debugger for the Sketchup Ruby API, thanks for pointing that out.
I do sprinkle puts statements throughout which is why I know my issue is at the trim step between these two solids.

EDIT: I attempted to get the debugger going but SU 2020 doesn’t have a good manual yet and all the tutorials are for 2019 or earlier with mixed IDE’s.

The objects are on the scale of inches.

The trim function works correctly if move the projection down a little.