In this example I have 3 cases, the first, where part1 and part2 overlap, the second, where part3 and part4 are in contact on 2 edges, and the third, where the parts do not overlap.
The following commands show how I have got the intersection (overlap1, overlap2, overlap3) between 2 parts using Face.section method:
Code: Select all
overlap1 = App.ActiveDocument.getObjectsByLabel('part1')[0].Shape.Faces[0].section(App.ActiveDocument.getObjectsByLabel('part2')[0].Shape.Faces[0])
Part.show(overlap1, "overlap1")
Code: Select all
overlap2 = App.ActiveDocument.getObjectsByLabel('part3')[0].Shape.Faces[0].section(App.ActiveDocument.getObjectsByLabel('part4')[0].Shape.Faces[0])
Part.show(overlap2, "overlap2")
Code: Select all
overlap3 = App.ActiveDocument.getObjectsByLabel('part5')[0].Shape.Faces[0].section(App.ActiveDocument.getObjectsByLabel('part6')[0].Shape.Faces[0])
Considering that the 2 parts overlap only in the first case, I would like to find a rule that allows me to check if 2 parts overlap. I have tried to use the isValid method and the BoundBox property, but I don't know how to differentiate the different cases, especially the second one.
Code: Select all
>>> overlap1.isValid()
True
>>> overlap1.BoundBox
BoundBox (-692.421, 697.849, 0, -623.344, 750.705, 0)
>>> overlap2.isValid()
True
>>> overlap2.BoundBox
BoundBox (89.8585, 374.475, 0, 158.935, 703.134, 0)
>>> overlap3.isValid()
True
>>> overlap3.BoundBox
BoundBox (1.79769e+308, 1.79769e+308, 1.79769e+308, -1.79769e+308, -1.79769e+308, -1.79769e+308)