Select by name filter, update and Matte material global override
Hello everyone :)
I'm relatively new to Max scripting so I have few problems to solve which I didn't found on help or other forums.
I want my script to, when selecting geometry, filter only geometry when selecting by name (multiple objects - only Geometry - no helpers, cameras, shapes or so), the same thing with cameras. Also, to check those, I want them to print in the text box under the buttons and connect selected camera to render button.
Then, when my objects are selected and printed, on "Update" button, next to render button, I want to apply a Global MATTE material override to selected geometry (mental ray) on chosen radio button "Front" - when "Front" is chosen - it should apply MATTE to previously selected geometry MESH objects and when Back is selected to do vice versa, to apply on objects that are not selected and printed in the box - I don't know how to do that so I'm asking someone to help and I would really appreciate it.
The script is in the attachment. Thanks in advance.
Attachment | Size |
---|---|
scriptproblem_02.ms | 2.52 KB |
Comments
select camera without target
hello :) I have just one more problem to solve but can't figure it out so If somebody can help me with just one more line of code.
I want script to collect Camera (without target) when opening. It can be selected by select by name that is filtered in class of cameras ("isKindOf") and it's working but I can't add that filter when opening and collecting camera automatically. In my every scene the camera has the same name "CAM_2_Front" and script, when is collecting, it grabs target object with camera too. I tried to filter it in some other way but it's not working, I got "call needs function or class, got: $Target_Camera:CAM_2_Front @ [-1.777199,-434.206512,187.059662]" problem. Few days of trying and still can't figure it out. Here's the code:
.
The same as in CGTalk:
Tools and Scripts for Autodesk 3dsMax
Thank you again :)
Kostadin, thank you, again, and here on scriptspot!
Cheers ;)
removed space on the end
Thank you, Pixamoon. Worked like a charm.
I just had to use rendName = substring rendName 1 (rendName.count - 1) to make it work. I know that this was very simple problem but, for a newbie like me it took few hours to figure out where to put this line of code X) I will study your method for materials, thank you for sharing.
Cheers
`
cool, yes, just remove b.selected and previous line with b and u ready:
Thank you! :D
You are genius and thank you for help :) Now I have 99% of script settled. Only I have one more issue to solve and still can't figure it out.. I want my sp_Material spinner to instantly change and assign those materials (which are collected from scene and in array and listed) to selected mesh or, if it is possible, let Max to found mesh in which has a name in it ("Head" in "MESH_Head_01" - that would be fantastic) and make that as a selection (just to avoid manually selecting in scene) I tried to access the material index via spinner.value but i got "--No ""get"" function for undefined" error. Here is the code and screenshot is in the attachment.
`
:) you're welcome
didn't have time to check a code but u can simply add
if classof x == Array then ......
it will skip all non array values
or
if x != undefined then ......
but in your case it can't get indexed value in array, so first one is better
cheers,
Pixamoon
select camera without target
hello :)
Just so you know the script is working great and big thanks for your help. I've been learning MaxScript and modified my script just like I wanted and it's very addicting thing to learn in Max.
Only I have just one more problem to solve but can't figure it out so If you can help me with just one more line of code.
I want script to collect Camera (without target) when opening. It can be selected by select by name that is filtered in class of cameras ("isKindOf") and it's working but I can't add that filter when opening and collecting camera automatically. In my every scene the camera has the same name "CAM_2_Front" and script, when is collecting, it grabs target object with camera too. I tried to filter it in some other way but it's not working, I got "call needs function or class, got: $Target_Camera:CAM_2_Front @ [-1.777199,-434.206512,187.059662]" problem. Few days of trying and still can't figure it out. Here's the code:
thank you for response, pixamoon
I figured it out some other similar way. I've already settled script 90% but still have few problems to solve.
First problem looks very simple but still can't figure it out. When rendering to a image it appears to be a "space" between pose name and extension ".png" I've tried trimRight, replace, and token commands on it but none of that is working... The screenshot is below in the attachment.
Second problem is that I want to connect material spinner to cycle through materials somehow. Problem is that Compact Material Editor has 24 free slots to fill with materials but I need 40+. I was wondering is there a way to connect Materials in Slate Editor to a spinner in script to cycle through materials.
Here I will post whole script and describe problem as close as I can.
I'm doing still poses (with biped) for a character with switchable face expressions and render them as separate: Head and body - on the same pose i can switch and render facial expressions defined by a diffuse map in separate material (number of facial expressions = standard materials in scene). This is for a game and those rendered images (body and few different expressions) are merged to a complete character. Later on, this will be animated with switchable faces with dialog text above and so on..
Scene is made from biped (and mesh skinned to it) MaxText with predefined poses for character formatted as ("pose number", "(space)", "pose name") for example "04 welcoming" - pose number is also timeslider number in Max just to found specified poses more easily (it can be to 200 poses). Materials are node-based in SME (because compact ME contains only 24 free slots to stock materials and I need 40+) - standard, selfillumination:100, diffuse map (face expression). It can be more than 40 different expressions to switch on a face mesh so I want that to be automated with spinner somehow too. Temporarily I have setup for expressions using state sets (each set is different material) and it can be easily changed in between.
I've written a script with big help from Jorge Rodríguez on forum "CGsociety" Everything works perfectly, just as I wanted. Only thing that I want to do to finish the script is to add a function to this spinner on top right of the script - material change. It should be a switchable materials in array with named materials in edittext - the same thing with rendering - only this time, in name of .png of expressions, it is named "pose name", "-" "facial expression(material) name" for example "welcoming-happy.png" Also, the diffuse map name is the same name as it is material for example: happy.jpg as a diffuse map to a happy.material.
All that I want is to connect pose spinner to a variable strings by changing time/poses and material spinner to expressions/materials. Sry for bad English, I'm trying to explain this as clear as possible. The code for whole script is below. Thank you in advance and I hope that there must be some kind of solution for that situation.
`
bit busy today, but to get materials from SME take a look on my method here:
http://www.scriptspot.com/3ds-max/scripts/sme-get-selected-materials
it's getting only selected but it is easy to create new view in SME and just get all materials from there
to remove space on the end:
cheers,
pixamoon