[Closed] material and scene statemgr problem
Hello i am new to maxscript and this boards but I have 1 or 2 question about the script im working on. please help.
I want to assign some materials to createdd objects but sometimes there are more objects witha similar name. My script becomes very long.
for obj in geometry do
(
if meditmaterials[i].name == obj.name then obj.material = meditMaterials[i]
if obj.name == "pietra01"then obj.material = meditMaterials[1]
if obj.name == "pietra02"then obj.material = meditMaterials[1]
if obj.name == "pietra03"then obj.material = meditMaterials[1]
if obj.name == "pietra04"then obj.material = meditMaterials[1]
if obj.name == "ter01"then obj.material = meditMaterials[1]
if obj.name == "ter02"then obj.material = meditMaterials[1]
if obj.name == "ter03"then obj.material = meditMaterials[1]
there are about 60 objects sometimes 10 with similar name. I learnd from the help and online that we can use * for select more objects. like $box* but I tried this and it doesn’t work
if obj.name == ter*
if objname == #[ter*]
if objname == #(ter*)
what can be done?
and i work on my own scenestatemanager. I made a listbox and made a button to refresh and works nice. I want to delete a scenestate with a button but I don’t know how to link back to scenestate. I can only remove the item from the list but not the scenestate.
my code:
listbox sslista "Statelist" pos:[725,2] width:100 height:8
button del "Delete" pos:[725,135] width:100 height:21
button refresh "Refresh" pos:[725,160] width:45 height:21
fn SSData sceneStatesName =
(
for i = 1 to sceneStateMgr.GetCount() do
(
local sceneSta = sceneStateMgr.GetSceneState i
append sceneStatesName sceneSta
)
)
on del pressed do
(
sslista.items = deleteItem sslista.items sslista.selection
)
on refresh pressed do
(
sceneStatesName = #()
SSData sceneStatesName
sslista.items = sceneStatesName
)
Ah and I have a other queston, I want to load and save all parts for scenestates except lightproperteis and lighttransforms, how can I do? where can I find the partslist for scenestatemgr. I didnt find in help and online.
I appreciate if you can help me.
Don’t test the name, you could simply use $ter*.material = meditmaterials[1].
and i work on my own scenestatemanager. I made a listbox and made a button to refresh and works nice. I want to delete a scenestate with a button but I don’t know how to link back to scenestate. I can only remove the item from the list but not the scenestate.
From the maxscript help:
Interface: sceneStateMgr [left]<bool>Delete <string>name
[/left]
[left]Deletes the scene state with the given name. Returns true on success, false otherwise.
Ah and I have a other queston, I want to load and save all parts for scenestates except lightproperteis and lighttransforms, how can I do? where can I find the partslist for scenestatemgr. I didnt find in help and online.
You can use this to get a list of the index:
for val in 1 to sceneStateMgr.partsCount() do (
format "Index (%): %
" (formattedprint val format:".2d") (sceneStateMgr.MapIndexToPart val)
)
Then use that in a Capture where you set the index values inside a bitarray.
sceneStateMgr.Capture "Test" #{3..10}
-Eric
[/left]
Matchpattern function is your friend
if matchPattern obj.name pattern:"myName*" do print "match"
-Johan
thank you ver much! material and scenestatecapture parts work great
I already found delete part in help but i need one state to link to match listname. im almost got it. so example terra scenestate name should get delete and terra state name in list.
on del pressed do
(
(
for o = sslista.items do
sceneStateMgr.delete (o as string)
)
if sslista.items.count > 0 and sslista.selection > 0 then
sslista.items = deleteItem sslista.items sslista.selection
)
but code is wrong. it delete 1 item from list but delete all scenestates. ups! must be string part.
but rest work fantastic. thank you Pixelmonkey and jhn.
I think the problem is here:
for o = sslista.items do
sceneStateMgr.delete (o as string)
You are telling it to delete all sslista.items from the sceneStateMgr. The removal of list items is in a different loop and that is why your results are different. You should delete the listitems and scenestates in the same loop to ensure they match up.
-Eric