Overlapping offset curve

I need to offset curves in a particular frame. The curve to be offset is obtained from the solid trim component. Sometimes there is one curve sometimes there are two. I am not able to get curves properly for my geometry.
multiple_cavity_curve_offset.gh (128.0 KB)
sample_geom.3dm (272.9 KB)

I have uploaded the programme file in which data is internalised and the respective geometry in case. I need the following ouput for a single and double cavity respectively shown in the image.

It would be great help if anybody can suggest me on how to do it.

but why in your definition the offset is not like in your sketch?

that is the problem. I can get offset curves if there is only single curve in frame, but if there are are two or more it results in undesired curves.

Have a try clipper plugin.

multiple_cavity_curve_offset_re.gh (236.9 KB)

i don’t understand what you want exactly
if you want something like the sketch you can try with this

Check this as well.

multiple_cavity_curve_offset_reV2.gh (120.2 KB)

Thank you man. I didn’t knew the polyline offset component before. Also i like the idea of using bounding box instead of using individual frames. I will try to implement it in my other programmes also. Thank you very much.