It is not the Modifier that needs updating. In the case of PRT objects, all modifiers are run by the base object (don’t ask!)
So all you have to do is request an update of the PRT Volume, and the modifier (if set to Auto), will update too.
If you would look at the code behind the “Update” button in MagmaFlow, you will find that it is simply changing a property in the Magma modifier to fool Max’ validity interval that something changed and it should update…
In fact, the code looks like this:
magma.autoUpdate = magma.autoUpdate
The more it rains, the more it rains…
This does not work completely with PRT Loaders because they have a dedicated viewport cache that keeps the particles. So the Update button in Magma also has this line:
local theNodes = for i in refs.dependentNodes magma where classof i.baseobject == KrakatoaPRTLoader do try(i.delegate.InvalidateObjectSpaceCache())catch()
This forces any PRT Loaders to drop their cache if they contain the given MagmaModifier (where ‘magma’ is the .MagmaHolder of the actual modifier)
So if you want to update a Magma modifier with a MAXScript, you can simply tell it to set autoUpdate to its own value.
And setting autoUpdate to true will enable the >AUTO button, obviously…
The code would look like
theMagmaMod.MagmaHolder.autoUpdate = theMagmaMod.MagmaHolder.autoUpdate
where theMagmaMod is a variable containing the Magma modifier you added.
Or, if you know it is the top modifier of the currently selected object, you can say
$.modifiers[1].MagmaHolder.autoUpdate = $.modifiers[1].MagmaHolder.autoUpdate
To set all Magma modifiers to Auto update, you could say
macroScript MagmaAutoOn category:"Krakatoa Tools"
(
for o in objects do for m in o.modifiers where classof m == MagmaModifier do m.MagmaHolder.autoUpdate = true
)
You could make a button on a toolbar that runs that code if you want to force all scene Magmas to auto-update with one click.
Alternatively, you can make a second icon with the code
macroScript MagmaUpdate category:"Krakatoa Tools"
(
for o in objects do
(
for m in o.modifiers where classof m == MagmaModifier do
(
m.MagmaHolder.autoUpdate = m.MagmaHolder.autoUpdate
for i in refs.dependentNodes m.MagmaHolder where classof i.baseobject == KrakatoaPRTLoader do
try(i.delegate.InvalidateObjectSpaceCache())catch()
)
)
)
which will perform an UPDATE of the modifiers without turning Auto on.