PDA

View Full Version : How can i write the maxscript?


sunboy69
04-21-2008, 01:50 PM
Closed!ZZZZZZZZZZZZZZZZZZ

ZeBoxx2
04-21-2008, 02:07 PM
not entirely clear what you're asking for..

Do you basically want a list of all objects that use a certain material / material with a certain texture map (presumably diffuse map, bitmap), but only if that material / map is used more than once in the scene?

j-man
04-21-2008, 02:35 PM
Hi sunboy69!

Are you trying to find duplicated materials? if so, how would you know if it is duplicate? by having the same name? I know you#'re working with multi sub object materials, can you use the clean multi material utility?

There are many difficulties and pitfalls working with muklti materials that can make material scripts quite complex.


Regards,

Josh.

sunboy69
04-21-2008, 02:35 PM
not entirely clear what you're asking for..

Do you basically want a list of all objects that use a certain material / material with a certain texture map (presumably diffuse map, bitmap), but only if that material / map is used more than once in the scene?

Yes you speak right very much! that's the meaning!!
I want to find out the same diffuse,specular and bump map which some objs use it on the different material(multi/sub-obj)
The list contains:
Some different objs(use the same texture)---material(or multi/sub-obj material) on the some objs---repeated diffuse,specular and bump map.Bucause i just use the three type of maps!
Maybe i can use the texture to find out which materials use it,and the texutre is changeless!
When i find out,i can delete other materials,and use the only one on some objs!

sunboy69
04-21-2008, 02:51 PM
Hi sunboy69!

Are you trying to find duplicated materials? if so, how would you know if it is duplicate? by having the same name? I know you#'re working with multi sub object materials, can you use the clean multi material utility?

There are many difficulties and pitfalls working with muklti materials that can make material scripts quite complex.


Regards,

Josh.
ah!!Thanks for your advice j-man.

Snoelk
04-21-2008, 11:21 PM
you could loop to all objects and get there materials or submaterials
if they got submaterials loop throu the submaterials
then you can access each materials maps
<Standard>.diffuseMap TextureMap
<Standard>.specularMap TextureMap
<Standard>.opacityMap TextureMap
<Standard>.bumpMap TextureMap

now you can make an array with the objects and there corresponding texturemaps and compare those

only an idea

Teirz
04-22-2008, 04:08 AM
Am i right to say that this is the procedure that is possible for you to take to solve your problem?

1. Reading all material info that's been used inside the scene
2. Keep a record array of each and every map that's been used in every slot. And recall the function in order to dive into the multilayer submaterial etc.
3. Find out the item with equal or more than 2 counts, meaning they are duplicated.
4. Display them.


Regards,
Sean

sunboy69
04-22-2008, 06:02 AM
Am i right to say that this is the procedure that is possible for you to take to solve your problem?

1. Reading all material info that's been used inside the scene
2. Keep a record array of each and every map that's been used in every slot. And recall the function in order to dive into the multilayer submaterial etc.
3. Find out the item with more than 2 counts, meaning they are duplicated.
4. Display them.


Regards,
Sean

Yes, maybe you're right!

Kenzor
04-22-2008, 09:58 AM
I have a script that recurses through all the materials in the scene. Looking for blend materials

rollout ViewRoll "Set blend mask"
(
radioButtons RBtnState Labels:#("on","off") default:2
button btnS "selected Objects" across:3
button btnM "material slot"
button btnA "Everything"

Local myState = false

fn FindBlend m =
(
myState = (RBtnState.State == 1)
c = (classOf m)
case c of
(
Multimaterial: (for SubMat in m.materialList do FindBlend SubMat )
Blend:( m.maskEnabled = myState )
compositematerial:(for SubMat in m.materialList do FindBlend SubMat )
DoubleSided:( FindBlend m.material1 ; FindBlend m.material2 )
Lightscape_Mtl:( FindBlend m.baseMaterial)
Shellac:( FindBlend m.shellacMtl1 ; FindBlend m.shellacMtl2 )
Shell_Material:( FindBlend m.originalMaterial ; FindBlend m.bakedMaterial )
TopBottom:(FindBlend m.topMaterial ; FindBlend m.bottomMaterial)
)
)

on btnM pressed do
(
m = meditMaterials[activeMeditSlot]
FindBlend m
)

on btnS pressed do
(
objList = (getCurrentSelection())
for obj in objList do FindBlend obj.material
)

on btnA pressed do
(
if scenematerials.count == 0 then
(
for obj in geometry do FindBlend obj.material
)
else
(
for m in scenematerials do FindBlend m
)
)
)

if DS != undefined do closerolloutfloater DS
DS = NewRolloutFloater "" 300 100

addRollout ViewRoll DS


The trick here is in the the recursive function call ... a function that calls itself ... as it loops into the material

j-man
04-22-2008, 10:05 AM
Hi,

maybe the problem is in the way you're detaching objects. If i detach objects i don't get a repeated material.
What is your proceedure?

Josh.

sunboy69
04-22-2008, 10:34 AM
Hi,

maybe the problem is in the way you're detaching objects. If i detach objects i don't get a repeated material.
What is your proceedure?

Josh.

Eh```Maybe this wasn't important now

Bercon
04-22-2008, 12:20 PM
Well I have a script that finds shared maps, but if you have several maps pointing to same bitmap texture then it wont detect it, building such detection shouldn't be too hard.

global findSharedMaps
try(DestroyDialog findSharedMaps)catch()

rollout findSharedMaps "Find Shared Maps" width:400 (
-- Shared
local foundMaps = #()
local foundParents = #()

-- Functions
fn gSubMaps map root = (
if map != undefined then (
local index = findItem foundMaps map
if (index == 0) then (
append foundMaps map
append foundParents #(root)
) else if findItem foundParents[index] root == 0 then (
append foundParents[index] root
)
showTextureMap root map false
for i in 1 to getNumSubTexmaps map do gSubMaps (getSubTexmap map i) root
)
)

fn gSubMatsMaps mat = (
if mat != undefined then (
for i in 1 to getNumSubMtls mat do gSubMatsMaps (getSubMtl mat i)
for i in 1 to getNumSubTexmaps mat do gSubMaps (getSubTexmap mat i) mat
)
)

-- UI items
button BUTTON_find "Find shared maps!"
listbox LISTBOX_found "" height:20

-- Events
on BUTTON_find pressed do (
foundMaps = #()
foundParents = #()
for i in meditMaterials where superClassOf i == Material do gSubMatsMaps i
for i in sceneMaterials where superClassOf i == Material do gSubMatsMaps i
local list = #()
for i in 1 to foundMaps.count where foundParents[i].count > 1 do (
local item = foundMaps[i].name + " : "
for j in foundParents[i] do item = item + j.name + ", "
append list item
)
format "list %\n" list
LISTBOX_found.items = list
)
)

CreateDialog findSharedMaps

sunboy69
04-22-2008, 02:25 PM
I have a script that recurses through all the materials in the scene. Looking for blend materials


Hi Kenzor! I'm very honoured that you help me to find the script,thanks!! but i'm mixed-up:
(1)The script i used in max8,9 is failing, it did't have any reflection.
(2)The script looks like to use for blend materials, can it work accurately on Standard or multi/sub-obj material?
I'm not sure if it worked accurately for you!

sunboy69
04-22-2008, 04:00 PM
Well I have a script that finds shared maps, but if you have several maps pointing to same bitmap texture then it wont detect it, building such detection shouldn't be too hard.


Oh dear Bercon,You're ingenious,the script was useful a certain extent, but there're any issue i'm not understand:
(1)When i run the script,it would delete many texture on objs(contain repeated or not), notice: the maps on my objs were only diffuse map!
(2)There're some repeated materials and textures that did't display in the script list, and it showed incomplete...

I did't know why?I hope you can help me to explain please. ^o^
However i must to thank you "Bercon".
Thanks!!

Bercon
04-22-2008, 06:03 PM
Its the other way around. On the left you have the name of the map. And entries after it are the materials that use that map.

And my script shouldn't do anything to the scene, it just lists the maps that are used in more than one material.

sunboy69
04-23-2008, 03:14 AM
Its the other way around. On the left you have the name of the map. And entries after it are the materials that use that map.

And my script shouldn't do anything to the scene, it just lists the maps that are used in more than one material.

If so ,but in my scene, there weren't some maps named "Map #5","Map#7","Map#10...and so on, i didn't know why?

And is it have an effect on multi/sub-obj ?

Teirz
04-23-2008, 03:32 AM
The Map #1,#2 etc are probably your submaterial's name that you might have miss out to change in your multi/sub material or submaps inside other material type e.g. blend, composite, shellac etc which Bercon has listed inside his script.

Try to use the map navigator to have a quick look on your material tree. From there you can probably spot those map easily.

sunboy69
04-23-2008, 07:47 AM
I'm very pleased that a great many master-hands help me!! Thanks very much```!
But there have a issue:
(1)
http://imgbj.jpg.name/hjytzvhwhhvythhyztswjtswhjjsdhzzwrzjy.jpg
(2)when i run the script ,i didn't know why it would delete any texture on any objs?
(3)Could the script have an effect on multi/sub-obj? if is, there were some multis that did't display in the list!
Can the script be amended, and how to amend?
(4)When i add this before running Rercon's script,the maps were decreasing,is it going to skip displaying some reduplicated materials?
For i = 1 to 24 do meditmaterials[i]=scenematerials[i]

CGTalk Moderation
04-23-2008, 07:47 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.