edwilliams16 wrote: ↑Thu Jun 16, 2022 10:27 pm
I think I mislead myself on the applicability of isEqual() isSame() isPartner() methods. I think they apply to shared geometry in a single object.
I was under the impression that object names were required to be unique.
https://wiki.freecadweb.org/Object_name
Both your "GDML_Box_det" objects claim to have the same "Valid Internal Name". At the very least this makes them difficult to differentiate in python references.
I tried
Code: Select all
Gui.Selection.clearSelection()
faces0 =[]
faces1 = []
for i in range(1,7):
Gui.Selection.addSelection('','World','Detector.GDMLBox_det.Face'+str(i))
sel = Gui.Selection.getSelectionEx('',0)
faces0.append(sel[0].SubObjects[0])
Gui.Selection.clearSelection()
Gui.Selection.addSelection('','World','Detector001.GDMLBox_det.Face'+str(i))
sel = Gui.Selection.getSelectionEx('',0)
faces1.append(sel[0].SubObjects[0])
Gui.Selection.clearSelection()
for i0, face0 in enumerate(faces0):
for i1, face1 in enumerate(faces1):
print(f'i0 {i0} i1 {i1} {face0.isPartner(face1)}')
since the Gui differentiates the objects - but it only identifies the corresponding faces ignoring the lateral shift.
I see your point, going to have to get my head around this.
Detector is a Part that contains GDMLBox_det.
Detector_001 is a Link Part and the Link is to Detector which contains GDMLBox_det, so yes the GDMLBox_det is the same object.
Now Detector_001 has a different Placement from Detector i.e. 2000,0,0 as opposed to 0,0,0 and hence the box is displayed with this Placement.
Now what I am after is what is the Common Face of the displayed boxes.
Now I thought that creating a new copy of the Shape(TopoShape) in Detector_001 and performing a translate would give me a suitable Shapes (TopoShapes) to compare,
hence
Code: Select all
def adjustShape(part):
print("Adjust Shape")
print(part.Name)
print(part.Label)
print(part.OutList)
print(f'Before Placement Base {part.Placement.Base}')
beforeBase = part.Placement.Base
if hasattr(part,'LinkedObject'):
print(f'Linked Object {part.LinkedObject}')
part = part.getLinkedObject()
print(part.Name)
print(part.Label)
print(part.OutList)
obj = getGDMLObject(part.OutList)
obj.recompute()
# Shape is immutable so have to copy
shape = getShape(obj)
print(f'Shape Valid {shape.isValid()}')
print(dir(shape))
#return shape
print(f'After Placement Base {part.Placement.Base}')
#return translate(part, part.Placement.Base)
return shape.translate(beforeBase)