[Closed] Automatically Add Custom Attribute?
It’s been a while since I played with Custom Attributes, is there a way I can automatically add a Custom Attribute to a textureMap class, if that class is created by user or script?
I want to have a little extra rollout added to a certain texturemap class that basically adds some presets UI. I have a CA set up that does this, just want it always there
plugin textureMap AdvBitmap
name:"AdvBitmap"
classID:#(0x00de00, 0xde00de)
extends:BitmapTexture
replaceUI:off
(
local AdvBitmapAttr = attributes AdvBitmapAttr attribid:#(0x00de01, 0xde00de)
(
parameters params rollout:params
(
)
rollout params "Advanced Attribute"
(
)
)
parameters params rollout:params
(
)
rollout params "Advanced Bitmap"
(
)
on create do
(
custattributes.add this AdvBitmapAttr
)
)
/*
a = AdvBitmap()
meditmaterials[1].diffusemap = a
*/
If you write your own (sdk) Texmap plugin you can use RefAdded method to handle all extras including Cust Attributes specific to the target (this)
Working with a scripting plugin, you can double-check for the presence of a CA on load or update using the appropriate event handlers, and add the CA if necessary.
yeah my first route was to look at making a texmap scripted plugin, but this relies on people remembering to use the ‘AdvBitmap’ instead of ‘Bitmap’. I wanted to make this only an extension to the existing map.
How do you specify what BitmapTexture needs extra CA and what does not?
For example, I won’t be happy if someone starts adding some CA to all my BitmapTextures in the scene …
Well in this case it is purely a studio-wide thing which would add a presets menu. BitmapTexture is not the target map here, a Vray one is.
Do you know? I have a local “security tool” for my clients that automatically finds and removes all CAs that I don’t know
If the presets will only be accessed manually through the max materials editor interface, it might be better to add CAs on demand when the user switches to / opens / creates a specific texture class.
Yeah and that wouldn’t break anything with this as it’s just basically a UI extension. I can have a script button of course to add this extension to all-in-scene or something but I’m just curious to see if it can be done automatically?
for sme you can try something like this, but I don’t know if it could provoke some slowdowns in views with lots of material nodes
it fires every time user activates some material or texturemap in param editor
deleteAllChangeHandlers id:#sme_test
when subAnimStructure trackViewNodes[#sme] changes id:#sme_test val do
(
format ">> % - %\n" (SME.GetMtlInParamEditor()) val
)