Is there any way I can access the bounding box properties of a PRT Loader?
I’m looking to get the extents in Z of the loaded data. I could use the particle data viewer utility since it shows min/max values, but i’m working with real-world scanned lidar files that take some time to scan all the points. Since the viewport draws the bounding box around the loaded points, I figured I could easily access those values (knowing that if the viewport was only loading 15% of the total points, values not loaded into the viewport would not be considered for the min/max) I’ve tried maxscript commands like nodeLocalBoundingBox and nodeGetBoundingBox, but it looks like that is returning values around the krak icon, not the points themselves.
Yes, you are missing something obvious:
The PRT Loader has a set of buttons to set the Modifier Gizmo Size to the current bounding box of the PRT Loader.
Since we ship the MAXScript source of all UI scripts with Krakatoa, one can actually look at what these buttons do - the actual code looks like this:
fn getBBoxSizeFromObject mode:#all =
(
if selection.count > 0 do
(
local theObj = selection[1]
local theOldTM = theObj.transform
theObj.transform = matrix3 1
local theMin = theObj.min
local theMax = theObj.max
theObj.transform = theOldTM
if mode == #all or mode == #x do gizmoBoxX = theMax.x - theMin.x
if mode == #all or mode == #y do gizmoBoxY = theMax.y - theMin.y
if mode == #all or mode == #z do gizmoBoxZ = theMax.z - theMin.z
)
)
Note that gizmoBoxX, gizmoBoxY and gizmoBoxZ are parameter tracks in the ParamBlock of the PRT Loader scripted plugin.
So you could simply reimplement this in your script and say
fn getBBox theObj =
(
local theOldTM = theObj.transform
theObj.transform = matrix3 1
local theMin = theObj.min
local theMax = theObj.max
theObj.transform = theOldTM
(DataPair min:theMin max:theMax)
)
Now you can call this function with the PRT Loader in question and you will get the min and max of the bounding box.
For example:
Most excellent. Thank you Bobo! I had seen the gizmoBox parameters but didn’t make the connection with the Ui Scripts and think to look there. I’ll dig into this now but I’m sure this is exactly what I needed.