Can I query if a curve intersect a surface trough the python API?

I need to trim a lot of curves at the crossing point with a several surfaces, doing it manually is impossible but if I trim a curve with a surface that do not intersect I get an error.

While I couldn’t find an API call that tests for a trim, here’s a couple of routines that might help you:

def check_curve_intersect_surface( cid, sid ):
  init_err_count = cubit.get_error_count()
  cubit.cmd( f"create vertex on curve {cid} crossing surface {sid} bounded" )
  if cubit.get_error_count() == init_err_count:
    trim_vert = cubit.get_last_id( "vertex" )
    cubit.cmd( f"delete vertex {trim_vert}" )
    return True
  else:
    return False

def split_curve_by_surface( cid, sid ):
  init_err_count = cubit.get_error_count()
  cubit.cmd( f"create vertex on curve {cid} crossing surface {sid} bounded" )
  if cubit.get_error_count() == init_err_count:
    trim_vert = cubit.get_last_id( "vertex" )
    cubit.cmd( f"split curve {cid} at vertex {trim_vert}" )
    cubit.cmd( f"delete vertex {trim_vert}" )

Nice did not know about the command get_error_count(), do you know if there is a way to silence the errors in the output in order to avoid “ERROR: Errors found during session”.
No biggie, but if a random error show up somewhere else will be difficult to notice.

Thanks a lot for the function if works great!

I think the inability to errors off was a conscious decision by the developers a long time ago. You turn off informational messages

set info off

or warning messages

set warning off

but not error messages. They were deemed too dangerous to ignore.

Thanks,
Karl