I am about to release an update to Wall Worm with this change. Below is a MAXScript that you can run before updating to store the current values that will be affected:
/*
struct WallWormEntityDataTypeHelper (
--values stored as strings that will be converted to floats in a custom attribute update and we need to store it because
stringsThatWillBeFloats = #("radius"), --make array in case we add more in future
/*
This script will embed entity parameters that are strings but will be converted to floats in a custom attribute update.
This is necessary because when a custom attribute parameter type is changed, it's current value is not kept (converted) but reverts to parameter default value.
*/
function storeCurrentValues = (
local updatedEnts = #()
for ent in ::WallWormHelperOps.entities WHERE isvalidnode ent do (
local ca = ::WallWormEntityOps.getEntCA ent
if ca != undefined then (
for p in stringsThatWillBeFloats do (
if isProperty ca p then (
local v = (getProperty ca p)
if classof v != float then (
setUserProp ent (("wallworm_entity_store_"+p) as name) (v as string)
append updatedEnts ent
)
)
)
)
)
if updatedEnts.count > 0 then (
selectionSets["Entities that Stored old values"] = updatedEnts
)
),
function retrieveOldValues = (
if ::WallWormHelperOps.entities.count > 0 then (
local paramsToCheck = #()
for p in stringsThatWillBeFloats do (
append paramsToCheck (datapair p (("wallworm_entity_store_"+p) as name))
)
for ent in ::WallWormHelperOps.entities WHERE isvalidnode ent do (
local ca = ::WallWormEntityOps.getEntCA ent
if ca != undefined then (
for p in paramsToCheck do (
local storedVal = getUserProp ent p.v2
if storedVal != undefined AND storeVal != "" then (
if isProperty ca p.v1 then (
--do a try because we cannot guarantee the string value can be converted to the data type
try (
setProperty ca p.v1 (storedVal as (classof (getProperty ca p.v1)))
) catch (
format "ERROR: Could not set % to % in %\n" p.v1 storedVal ent
)
)
)
)
)
)
)
)
)
::WallWormEntityDataTypeHelper = WallWormEntityDataTypeHelper()
To use this
- click Scripting > New Script
- Paste that code into your MAXScript File
- Click Tools > Evaluate All (CTRL+E)
- In the MAXScript Listener (F11) paste this code and then hit ENTER: ::WallWormEntityDataTypeHelper.storeCurrentValues()
Now the script will store the current values.
To retrieve the values after you update Wall Worm, you can then run this command in the MAXScript listener:
::WallWormEntityDataTypeHelper.retrieveOldValues()
IMPORTANT NOTE: You must run this code
before updating to Wall Worm 5.0.41+ on each scene that you want to preserve the radius values of entities. If you do not have entities that use the radius parameter (or the radius was already defined as a float in the FGD you are using), you do not need to concern with this script.