[Closed] material editor help
hi all …i am a beginner in 3d max and i want to do a simple task …can any body help me plz
i want to :
1)go to material editor toolbar to get material
2)choose selected and double click on material
3)from basic parameters : diffuse and press the button beside the color
4)from co-ordinates : map channel =2
5)assign material to view port
6)show map in view port
plz guys i really need your help
thx in advance
Am I understanding you right? You want a script that changes the Map Channel of the current selected object’s material to 2 and set it to be show in viewport?
In this case:
$.material.DiffuseMap.coords.MapChannel = 2
showTextureMap $.material $.material.diffuseMap true
(Works only with single selected objects and basic Materials…if you use Multi/Sub-Object or Blend Materials or any other Material that doesn’t have a Diffuse Map Channel, it will fail.)
i meant to do it for multi -complicated- objects … i want this script to do these changes for selected objects
While I applaud your attempt to list the steps you want to automate (which is usually the best way to get to a good script), you should describe WHAT should be done, not HOW it should be done because MAXScript does not necessarily work the way the UI and mouse are used in Max. It is a programming language so you will have to think at a different level.
-
Keep in mind you don’t need to use the Material Editor to get a material from the scene, material library of even the Material Editor itself! (sounds crazy, but it is true). So if you want to let the user pick a material from a selected object (or many materials from many selected objects), there are simpler ways to do that. If you want to apply the mapping channel 2 change to any number of selected objects, you would simply need to loop through the selected objects with a FOR loop and apply the same operation to each one’s material.
-
Keep in mind that not all materials have a valid Diffuse Map and not all Maps use Mapping Channels as default projection method, so it might be a good idea to check that accessing the diffuse channel of the material is even possible (if the object has a Multi/Sub material for example, it has many sub-materials which might have diffuse mpas, but the top level material does not).
-
If you are making the changes directly to the scene objects, applying the changes to the material will be reflected immediately without having to assign back. You would be working directly with the already assigned materials.
So a description of what you want to do would look more like
- For every selected object in the scene
- Get its material and if it is a valid material and not ‘undefined’
- Try to access the .DiffuseMap channel of the material and if this did not fail
- Try to change the map channel to 2
- Enable the Show Map In Viewport for the DiffuseMap of the current Material
This could be made even more advanced if you checked the class of the material and repeated the steps 3,4 and 5 for any sub-material in a MultiSub, DoubleSided, TopBottom etc. materials.
I know if did not solve your problem (Piflik almost did), but I am trying to help on a more general level of learning MAXScript.
i really dont know how to thank u … u are a real expert bro :)…thx again
and i wish i didnt disturb you
That would be the basic translation for Bobo’s advice. Still no support for Multi/Sub-Object Materials and the likes…but it should work fo selection sets and shouldn’t produce errors if encountering a ‘bad’ Material…
for i in selection do
(
try
(
i.material.DiffuseMap.coords.MapChannel = 2
showTextureMap i.material i.material.diffuseMap true
)
catch()
)
I tried to construct a script that does all of what Bobo suggested, but it is entirely untested…(and still doesn’t support all Materials).
It tests the Material of every selected Object and if it is a Blend, Composite, Multi/Sub-Object, Shellac or Top/Bottom Material, it repeats the test for all of their Submaps. When the Material is none of the above, it tries to set the Material’s Diffuse Map to Map Channel 2. Obviously it doesn’t work for Materials that don’t use a Diffuse Map (just like the Script posted above).
fn MapChannel2 MyMat
(
try
(
MyMat.diffuseMap.coords.mapChannel = 2
showTextureMap MyMat MyMat.diffuseMap true
)
catch()
)
fn MatTest MyTestMat
(
case of
(
(MyTestMat == BlendMaterial):
(
MatTest MyTestMat.Map1
MatTest MyTestMat.Map2
)
(MyTestMat == CompositeMaterial):
(
for m in MyTestMat.materialList do MatTest m
)
(MyTestMat == MultiMaterial):
(
for m in MyTestMat.materialList do MatTest m
)
(MyTestMat == Shellac):
(
MatTest MyTestMat.shellacMtl1
MatTest MyTestMat.shellacMtl2
)
(MyTestMat == TopBottom):
(
MatTest MyTestMat.topMaterial
MatTest MyTestMat.bottomMaterial
)
default: MapChannel2 MyTestMat
)
)
for i in selection do MatTest i.Material
My script does this stuff pretty easily:
http://www.scriptspot.com/3ds-max/modifier-modifier-zorb
I used the method of using getclassinstances and then refs.dependantnodes to check if it was associated with the selected objects.
Can be slower but is seems to be a much more accurite way of getting materials.
Opps, miss-read a little, it can do it for different texture map classes on an object, not explicitly the diffuse channel
Wouldn’t something like this work?
Just get all the standard materials, if they have a diffusemap then change the mapping channel to 2 and show in viewport, no need to itterate through Blends/multisubs etc…
for o in getclassinstances StandardMaterial do
(
try
(
o.diffusemap.coords.mapchannel = 2
Showtexturemap o o.diffusemap on
)
catch()
)