I’m attempting to get the OBB for a set of parts, but I’m not getting expected values from using getOBB.
I’ve tried this with more parts, but as an example if I use it on a single part located at the translation point: 11283.1,-1297.43,2225.06
I get this return:
pxz.geom.OBB(pxz.geom.Point3(22556.07639095168, 4418.216988201847, 2558.437568865675), pxz.geom.Point3(3.663600502432114, -18.692777221409962, 47.057729049575684), pxz.geom.Point3(9.040980636295075, -0.7059574012008597, -0.9842983621514242), pxz.geom.Point3(10.087270977685899, 83.84314311238376, 32.519747459729196))
The object is listed in documentation as returning a corner and the 3 axis. The axis look essentially correct to me as it is a relatively small part, but shouldn’t the corner be near the part’s translation?
I run this prior to getting the OBB to correct for scaling issues between parts (I think):
scene.resetTransform(1, True, False, False)
for occurrence in scene.getPartOccurrences():
scene.movePivotPointToOccurrenceCenter([occurrence], False)
Is [11283.1, -1297.43, 2225.06] the translation after running your script?
If so it should indeed correspond to the center of your occurrence bounding box. Having the corner so far off (around 11 or 12m) is weird.
Can you try running this script and check what it returns?
I’m sorry. I just realized that I misunderstood what you meant AND I also made a mistake. I had not yet run that script that resets the pivot points. After running it the translation of that part is actually: [11283.1,2225.06,1297.43]
If I run your script after that I get:
[2024/10/16 13:42:58] executing command scene.getAABB
[2024/10/16 13:42:58] occurrences: [961755]
[2024/10/16 13:42:58] Command execution time : 0.000 s
[2024/10/16 13:42:58] pxz.geom.Point3(11283.1, 2225.06, 1297.4300000000003)
Getting the OBB for that same part after the pivot resets gives:
[2024/10/16 13:45:06] pxz.geom.Point3(22556.034997970815, 4418.220061857224, 2558.440436311508)
The translation you see in the UI is local to its parent (local coordinates).
Because you reset all the occurrences using scene.resetTransform(1, True, ...) and move the pivot point to the occurrence center now it matches the global translation in world coordinates.
It seems to match the AABB center so that’s good.
But the OBB corner is off. So maybe the part is not that small… Can you print the aabb.high and aabb.low values as well so we can check that?
Unfortunately I can’t share a screenshot of the geometry, but here is the translation data. There is an occurrence component attached to the part as well so not sure if that might be affecting anything…
Here is low then high:
[2024/10/16 17:45:02] pxz.geom.Point3(11277.680015463042, 2182.289130854579, 1267.5261161890528)
[2024/10/16 17:45:02] pxz.geom.Point3(11288.602770498686, 2267.8247218346673, 1327.32814891928)
I need to find a series of parts within the OBB. I tried with AABB first, but that was grabbing more parts then I wanted.
However, I get this error:
[2024/10/17 11:26:15] Traceback (most recent call last):
[2024/10/17 11:26:15] File “”, line 17, in
[2024/10/17 11:26:15] pxz.geom.Error: Matrix Transformation for this type of entity (Occurrence) is not supported yet
scene.setLocalMatrix would be more appropriate here.
scene.applyTransformation applies the translation/rotation/scale to the current occurrence translation/rotation/scale and works in your case because the current occurrence transform is set to identity (centered on origin, with no rotation and a unit scale).
Coming back to this topic, can you describe what exactly the return of the getOBB function is? The OBB type is listed as containing a point3 of corner and three vector3’s of xAxis, yAxis, and zAxis. The way I have been thinking about this would be that the corner is the corner of the box with the lowest x, y, z values and each vector is normal to the surface of each side of the box and ends on the plane that makes that side. Is that a correct way to interpret that?