ScriptSpot

Forum topic · General Scripting

Add note to material library

By Andreas G · 2013-04-17

Description

Hi!

Does anyone know if it's possible to add a note to a material. Not like a map. More like info stored in the material library file.

Thanks!

Comments (8)

Andreas G · 2013-04-18

This is great!
But if I use example#2 and at a later time wan't to access the note how do I do that? I tried a few ways but I can't seem to get it to work.

Thanks so much for your help!

barigazy · 2013-04-18

What do you try?

Andreas G · 2013-04-18

First I add the ca to the material, then I add it to a matlib and saves it. At a later time I wan't to load that matlib and access the note and print it to a edittext

I'm trying to access the note with custAttributes.get mat materialNote but all I get is undefined

Thanks

barigazy · 2013-04-18

Let's say you put material from the library which already have note inside to material slot 3.
Now to get note simply use


meditMaterials[3].mtlNote.note

If you assigne that material to en object (Box001 for example) then you can use


$Box001.material.mtlNote.note

And to set new note just do


$Box001.material.mtlNote.note = "This is my new material"

Andreas G · 2013-04-18

That was easy! Thanks again!

Andreas G · 2013-04-18

Thanks for the reply!
I'm going to look at it today.

example #2 (visible notes)

barigazy · 2013-04-17

Also you can add new rollout inside any material

--CA definition
materialNote = attributes mtlNote
(
parameters notesParm rollout:notesRoll
(
note type:#string ui:et_note
)
rollout notesRoll "Material Note"
(
edittext et_note height:100
)
)
-- example (you can use any material from ME, from object, from library)
mtl = meditMaterials[1]
-- the next line will assigne new rollout to material only if not exists
if not (isProperty mtl #mtlNote) do custAttributes.add mtl materialNote
-- now you can get/set some text
mtl.mtlNote.note = "Standard gray material"
--or if you want to extend existing note
mtl.mtlNote.note += "\nStandard gray material"
-- open material editor and look "Material Note" rollout inside first matrial.

example (hidden notes)

barigazy · 2013-04-17


-- define and store note in variable
txt = "This is a custom material note text.\nCheck similar example in MXS Help."
--define custom attributes to hold main function
materialNote = attributes mtlNote
(
fn getNote = (format "Note: %\n" txt)
)
-- example (you can use any material from ME, from object, from library)
mtl = meditMaterials[1]
--assigne CA to material
custAttributes.add mtl materialNote
---------------------------------------------------------
-- now to get note you need first to get material CA
ca = custAttributes.get mtl materialNote
-- then check if ca exists but if not send a message
if ca != undefined then ca.getNote() else messageBox "This material not have any note!" title:"MaterialNote" beep:off