Find Volume overlap in python

Hi,

I would like to use the “Manage Gaps and volume Overlaps” in python because I have a lot of little overlap zone in my CAD. Is it possible ? How I can do it ?

Thank you.

Best regards,

Rocco

Hi Rocco,

i am sorry i could only find something for handling the overlaps but not the gaps yet. It seems gaps can only be handled via C++ currently.

Lets first create some geometry with overlaps and gaps.

#!cubit
reset
create brick x 1
create brick x 1
create Cylinder height 1 radius 0.2 
create Cylinder height 1 radius 0.2 

move vol 1 y 0.5
move vol 2 y -0.499
rotate Volume 3 angle 90  about X
rotate Volume 4 angle 90  about X
move vol 3 y 1.501
move vol 4 y -1.498

The geometry got 2 overlaps and one gap.

With python you can search for overlapping volumes and execute the first solution for each overlapping pair in a loop.

#!python
maximum_gap_tolerance = 0.0001
maximum_gap_angle = 5
all_vids = cubit.parse_cubit_list("volume","all")

vids =  cubit.get_overlapping_volumes(all_vids)
for i in range(int(len(vids)/2)):
 volume_id_1 = vids[2*i]
 volume_id_2 = vids[2*i+1]
 solutions_overlap = cubit.get_solutions_for_overlapping_volumes(volume_id_1,volume_id_2,maximum_gap_tolerance,maximum_gap_angle)
 if len(solutions_overlap)!=0:
  #execute first solution
  print(solutions_overlap[0][0])
  cubit.cmd(solutions_overlap[1][0])
  #print(solutions_overlap)
  #print(volume_id_1)
  #print(volume_id_2)

print("finished")

Checking for overlaps with the power tools again will now only show us the remaining gap.

grafik

I hope this can help you a bit. I will keep you updated if i find something for the gaps in python.