/r/Maxscript
Everything Maxscript. Because it's a very powerful tool to know how to use with 3DStudio Max.
Questions about MAXScript, links to tutorials, posts with resources and downloads of scripts (that you have made yourself or have been made available for public use by the author) and just general discussions on MAXScript-related things.
What is MAXScript? It's a native scripting language for 3DStudio Max that allows the user to automate tasks and really tinker around with the guts of max to really make the experience of doing stuff with Max a lot easier and faster.
It's also a valuable language to know if you want to get into using Max on a level that's more than just modeling, animating and rendering. It can really give you an edge to really streamline your process and if you're aiming to be a rigger/TD then this is going to be a tool you'll want in your belt because it can take something that might take you a couple days to do and condence it down into a couple clicks of a button.
Guidelines for posting something:
If it is your script then feel free however please make sure to list in the body of the post if you are facing any bugs (especially "critical" bugs that might crash MAX or corrupt a save so that users are aware of the risks.)
If it is not your own script then please be sure to give credit to the author. Be kind and respectful of their wishes as well because if they are posting them behind a pay-wall and you're giving people an avenue around that, that's pretty shady (we all have to eat, after all) so if there is a pay-wall, link people to where they can pay the author so that they can benefit from their scripts in the way that they intended them to be released.
If you need help fixing a script or are needing some assistance with one, be sure to ask nicely! We're all a community of people and though you might be frustrated with the script, take at least a couple seconds to calm down before posting because a hot-headed post isn't likely to gain the same level of traction as a calm and collected post will.
If you want to advertise, we're not against it here... Everyone has to eat... But try not to spam and try to keep the advertising posts to once a week. If you are advertising multiple products at the same time, try and put together a "digest" post where you link to all your products. If there are too many complaints about spammy posts, however, understand that our first responsibility is to the community and if we feel that things are getting out of hand we will take action to keep the vibe here friendly and helpful. So, use your better judgement and ask yourself how you'd feel if you were on the other side of the keyboard.
And one last thing... Personal attacks are not cool and will not be tolerated. We understand that people can get passionate but flame wars, trolling and personal attacks are not going to be tolerated here. Users that DO engage in flaming, trolling, attacking or otherwise making this sub unpleasant to the user will be actioned.
Memes and other fun posts are going to be given the tentative okay for now... However, keep them on the subject of maxscript and relevant to this sub. And if they are spammy or getting out of hand in any way, that may lead us to revising this rule. Again, we're here to have a fun and friendly community that can help people learn to be better coders. This isn't the place to go digging for link-karma.
Above all else, be kind, courteous and helpful. And remember, we were all "noobs" at some point.
DISCLAIMER
Though every effort will be taken to be sure that things are O.K. here, we cannot be held responsible if the use of any script found here results in lost data or a corrupted save or any problem. All scripts found here can and may contain bugs or errors and we will not be held responsible for your use of scripts found here if they result in lost data, time or otherwise... Use your better judgement and be sure to protect your data whenever possible by practising good measures to protect your data and your computer.
/r/Maxscript
What the title says. I need a relatively complex (I think) script quicker than my learning curve allows. Who’m I gonna call?
Hi all, I want to return the number of currently selected edges within the editable/edit poly modifier, how can I do this?
I tried (polyop.getEdgeSelection $).count but it just returns the count of all edges in the current object, not the ones selected.
Many thanks for your help.
I want to change node: bitmap node to another node. I don't see much useful information on google or gpt chat about this issue. Thanks.
I have the code to get the node, but I don't see any documentation that can change the retrieved node.
for o in getClassInstances Bitmaptexture do (print o.fileName)
I wonder if someone can help me with this...
I wanted to make a script to find all the objects in my scene with real world maps. This is what I've got so far:
(
function collectRealWorldMats = (
local rwMats = #()
for o in objects where o.material != undefined do appendIfUnique rwMats o.material
for mat in rwMats do (
for m=1 to mat.numsubs do (
if classof mat[m] == SubAnim and superclassof (tM = mat[m].object) == textureMap do (
if mat[m].realWorldScale do
print mat.name as string
)
)
)
)
collectRealWorldMats()
)
this runs but I have several problems with it.
First of all, I have no idea how to select the objects. This is the smaller issue, even just printing out the names helps a lot.
The real problem is that this only works with really simple materials. As soon as I have a colour correct/mask/anything that introduces sub levels, the script breaks.
Any idea how to make this work?
thanks!
I need to run this code on multiple files. But sometimes it crashes and 3Ds Max closes ending my loop. I tried the try-catch statement but it didn't work.
Can anyone please guide me?
function turnToPoly = (
for obj in geometry do (
if isKindOf obj GeometryClass do
(
local turnToPolyMod = Turn_to_Poly()
turnToPolyMod.removeMidEdgeVertices = off
turnToPolyMod.keepConvex = on
addModifier obj turnToPolyMod
)
)
)
Hi,
trying to write a script that detaches faces to separate objects based on their vertex color. No luck.
Any ideas?
obj = selection[1]
convertToPoly obj
for f = 1 to obj.numfaces do
(
verts = polyOp.getVertsUsingFace obj f
color = polyOp.getVertColor obj verts[1]
sameColor = true
for v in verts do
(
if(polyOp.getVertColor obj v != color) then
(
sameColor = false
break
)
)
if(sameColor) then
(
polyOp.detachFaces obj #{f} asNode:true
)
)
I'm trying to make my script more readable and for the declaration of the struct it is beautiful:
struct SequenceBase
(
Name,
Spline,
Dolly,
LockTargetToCam,
FocusDist,
FStop,
TargetPos,
SplineHeight,
Rotate,
Speed,
Start,
End
)
But when it comes to assigning values I have to type everything in one long line like this:
Sequence[ActiveSequence] = SequenceBase Name:EA_Rollout.txtSeqName.text Spline:SplineList[EA_Rollout.DDLPathSelection.selection] Dolly:EA_Rollout.DollyCam.value LockTargetToCam: EA_Rollout.chkLockTarget.checked FocusDist:EA_Rollout.spnFocus.value FStop:EA_Rollout.spnDOF.value TargetPos:Cam.Target.pos SplineHeight:EA_Rollout.spnArcSpline.value Rotate:EA_Rollout.spnRotateObj.value Speed:EA_Rollout.spnSeqSpeed.value Start:SequenceMarkStart End:SequenceMarkEnd
Is it possible to make this last line comma-separated or in another way make it look more structured?
I hope someone can help me out here. (It's probably a very basic misunderstanding on my side)...
I have a rollout with lots of buttons and sliders.First button is a load-button to load a model into max, and the following sliders and buttons can access the properties of the object and for instance rotate the object.But when I run the script, I get a lot of errors because the sliders don't yet know the object or the properties of it...Now, how do I get around this problem?Ideally the bottom of the rollout shouldn't be active until an object has been loaded.
I have tried with two rollouts as floaters where the second one doesn't load until there's an object. But then I get errors in THAT part because Max STILL doesn't know anything about the object yet.
Can someone tell me in what order Max evaluates the script?
I need to make all the instances in an array unique, how can i do that?
Hi to everyone. I am animator and recently noticed a ridiculous problem in 3ds max. As you well know you can save and load animation in 3dsmax easily. It have "relative" option in loading that make it more useful. But the problem. If your object is linked to another one the relative option not working and result is "absolute".even there is no different if you try it in "save load animation" in curve editor right click menu. So I think to scripting. The script that do this in curve editor: 1-Set selected keys into an array.it should be dependent of object and track name so it can operate on any track. 2-Subtract last array member value from first one. And hold it into something like "A" or copy it to clipboard. 3- Subtract last array member frame number from first one. And hold it into something like "B". 4-move the selected keys to "B" frame after 5-add "A" to the values of selected keys . My main problem is the "1-" making right array. I Know this is very basic idea. Thanks for better ideas and any help.
Hi, I am very new to maxscript and I want to simplify vray and corona materials with maxscript.
I want to connect each and every map directly to its corresponding socket. Please check the attached example below to get a clear idea.
If anyone can help I will be very grateful as I want to do this on 100s of materials.
Thanks
Hey everyone - I’m new to Maxscript and struggling to get some things to work. Wondering if someone might have an idea to help out.
I have a model with many mechanical components. I created a dummy helper object called MechanicalSystem and used this dummy as the parent for all of the components in the model - in other words, all of the model components are nested within MechanicalSystem.
For the mechanical system dummy object, I created a custom attribute called BeamRotation that is linked to the Euler rotation of one of the model components.
The hierarchy thus shows as the following: MechanicalSystem
I am trying to use the selectTrack function to select the BeamRotation custom attribute in a Curve Editor trackview but I am not sure how to write the indexing.
I am trying the following but keep getting errors:
nCurve = trackviews.gettrackview “Rotation” nCurve.selectTrack MechanicalSystem.custom_attributes[#BeamRotation] True
Does anyone have any ideas of how I can select the custom attribute this way?
Thank you!
This is a script that puts a ColorCorrection on every map, but just want it to be applied to the Diffuse map.
Thank you.
fn AddColorCorrection m =
(
if isKindOf m VRayMtl then
(
for p in getPropNames m where isKindOf (tex = getProperty m p) textureMap do
(
if not isKindOf tex Color_Correction do setproperty m p (Color_Correction name:("CC" + trimleft p #texmap) map:tex)
)
)
)
for o in selection where (mat = o.material) != undefined do AddColorCorrection mat
I am trying to use MAXScript to add VRay elements to the Bake to Texture utility in 3ds Max 2022, specifically VRayExtraTex. For instance, this code adds the complete map:
bakeToTexture.addmap $ #CompleteMap
I can’t find a list of commands for the VRay elements. For instance, this does NOT work:
bakeToTexture.addmap $ #VRayExtraTex
Does anyone know where to find info on the Bake to Texture utility (not Render to Texture) for VRay elements and how to script for it?
Thank you.
I have vertices that are selected by another function. It doesn't matter which vertex, but I need to reduce this selection to one. I just can not figure out how this is done to manipulating the array in Editable Poly mode?
Can anyone help? Thanks
Hi, one of our animator wants block out biped animation.
It can be done in manual by convert quaternion to Euler rotation mode then set curve tangent to step via Workbench or Curve Editor. Working with Euler Curves on Biped Animation
I wonder how this can be automated with maxscript.
Hi, does anyone faced the same problem? I couldn't find the answer.
I'm used to C# and Maxscript is a bit alien at this stage.
I have an object selected, and I would like to get the child of the object - I can get the parent, the children, but finding the single child below the current object is proving difficult.
I have a single parent node with several children I can deal with later recursively.
Looking for some help on fixing my code or paying someone to write a small code for me.
Serious inquiries only please.
Hi guys i have looked around for scripting vertex weld solutions... but i'm only fining examples for Object mesh (meshop.weldVertsByThreshold) and polys, but not splines.
Im trying to make a script that:
Thanks in advance
With this script you can Find what kind of object and material IDs you have in your scene.
You can give random IDs and you can delete some of them .
Wish you a nice day 😊
20 yrs using max no idea how to use max script. Any kind stranger's want to help me out? Would be much appreciated.
I'm using the following code to populate the Max Batch Render utility with a view for each camera in the scene:
for b = batchRenderMgr.numViews to 1 by -1 do
(
temp = batchRenderMgr.GetView b
temp.overridePreset = false
temp.outputFilename = (edtxt_outputPath.text + "\\view0" + (b as string) + ".jpg")
temp.presetFile = "C:\\Presets\\production.rps"
)
The preset file exists, the path is correct, and the script throws no errors when executed. However, nothing appears in the dropdown list for presets. Does anyone know why, and how to force it?