[Closed] Accessing custom attributes
Hi all,
I’ve pieced together a way to add custom attributes to an empty modifier on an object from a separate post in the forums here. What I’m looking for is a way to collect all objects in the scene which will have these custom attributes and their values. This is independent of 3DSMax session, i.e., I should be able to access these even if I open a new scene, or restart max.
function addExportAttributes exportNode =
(
ExportModifier = emptyModifier name:"Export_Attributes"
addModifier exportNode ExportModifier
AttribDef = attributes ExportAttributes
(
parameters ExportParams rollout:assetRollout
(
assetType type:#integer ui:dropdwn_assetType default:1
exportable type:#boolean ui:chk_exportable default:true
)
rollout assetRollout "Root Node"
(
dropdownList 'dropdwn_assetType' "Asset type" pos:[0,0] width:160 height:40 items:#("Mesh", "Rig","Animation","Vfx")
checkbox 'chk_exportable' "Exportable" checked:true pos:[0,45] width:65 height:19
)
)
custAttributes.add ExportModifier AttribDef
)
I add it to an object by running
addExportAttributes $
I can select the object and get the value of
$.modifiers[#Export_Attributes].ExportAttributes.assettype
However, I want to collect a list of the objects in the scene which might have this empty modifier with these custom attributes added. I also would like this functionality to be global. Preferably, I don’t want to depend on modifier name or position since the animators might add extra modifiers to the stack, or worst case, rename the modifier. Would be great to get some input on this. Thanks.
ExportAttributes = attributes ExportAttributes attribId:#(0x3a3b62fe, 0x316f97de)
(
parameters ExportParams rollout:assetRollout
(
assetType type:#integer ui:dropdwn_assetType default:1
exportable type:#boolean ui:chk_exportable default:true
)
rollout assetRollout "Root Node"
(
dropdownList 'dropdwn_assetType' "Asset type" pos:[0,0] width:160 height:40 items:#("Mesh", "Rig","Animation","Vfx")
checkbox 'chk_exportable' "Exportable" checked:true pos:[0,45] width:65 height:19
)
)
function addExportAttributes exportNode =
(
local ExportModifier = emptyModifier name:"Export_Attributes"
addModifier exportNode ExportModifier
custAttributes.add ExportModifier ExportAttributes
)
fn getAttributeNodes =
(
local nodes = #()
for attrib in getClassInstances ExportAttributes do
for dependent in refs.dependents attrib do join nodes (refs.dependentNodes dependent)
return nodes
)
Brilliant. That worked. Appreciate you taking the time to post the working code. Thanks