/r/Maxscript

Photograph via snooOG

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

252 Subscribers

2

What’s the best platform to hire a freelance maxscript developer?

What the title says. I need a relatively complex (I think) script quicker than my learning curve allows. Who’m I gonna call?

11 Comments
2024/10/23
03:01 UTC

2

How to get the count of currently selected edges in the viewport?

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.

0 Comments
2024/09/27
11:39 UTC

1

How to replace material node in material state editor

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)

https://postimg.cc/VSM6WccX

1 Comment
2024/07/19
13:40 UTC

1

selecting objects with real world maps

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!

2 Comments
2024/05/28
16:06 UTC

1

3Ds Max crashes while running script

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
		)
	)
)

0 Comments
2024/04/19
13:57 UTC

1

select and detach faces by vertex color

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

)

)

3 Comments
2024/01/16
05:30 UTC

1

A little help with structs?

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?

2 Comments
2023/09/07
08:47 UTC

1

Help with rollout variables

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?

2 Comments
2023/09/04
08:58 UTC

2

Urgent! how to make instances unique Maxscript?

I need to make all the instances in an array unique, how can i do that?

1 Comment
2023/08/14
14:34 UTC

1

save- load animation problem

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.

0 Comments
2023/01/15
17:08 UTC

1

Simplifying Vray and Corona Material with maxscript

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.

https://preview.redd.it/2y25gzvlid9a1.jpg?width=2404&format=pjpg&auto=webp&s=a614219ff2e0b85a719e6d2c6133c68b6c109886

If anyone can help I will be very grateful as I want to do this on 100s of materials.

Thanks

0 Comments
2023/01/01
06:11 UTC

3

Delete Invisible Polygons

0 Comments
2022/10/19
20:35 UTC

1

corona material - create, assign, modify via maxscript - how to? Please help, my bruddahs 🤝

3 Comments
2022/08/26
04:28 UTC

1

How to Use selectTrack to Select a Custom Attribute in a TrackView

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

  • Transform
  • Object (Dummy)
    • Custom_Attributes
      • BeamRotation

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!

0 Comments
2022/06/28
19:40 UTC

3

Maxscript : Arrays - Iteration

0 Comments
2022/05/10
16:45 UTC

2

Maxscript : Arrays

0 Comments
2022/05/06
09:08 UTC

2

Maxscript: Using the $ sign!

0 Comments
2022/05/04
09:11 UTC

2

How can I make simple modification to this script

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

8 Comments
2022/03/01
10:32 UTC

1

Bake to Texture VRay elements

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.

2 Comments
2022/02/28
18:50 UTC

1

Selecting a single vertex out of an array of vertices

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

1 Comment
2022/01/25
11:53 UTC

1

How to access Euler curve tangent of Biped Object?

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.

0 Comments
2022/01/19
10:35 UTC

1

objXRefMgr question: How to access the "Match Layers By Name And Parent" checker option from the Xref Objects UI dialog via maxscript?

Hi, does anyone faced the same problem? I couldn't find the answer.

0 Comments
2022/01/13
14:57 UTC

1

Getting a single child in hierarchy

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.

2 Comments
2021/11/10
15:19 UTC

2

Maxscript offer - small code

Looking for some help on fixing my code or paying someone to write a small code for me.

Serious inquiries only please.

5 Comments
2021/11/09
02:41 UTC

1

Weld vertecies of editable spline

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:

  • loops through only the "Editable Splines" individually (classof i == SplineShape do)
  • selects the sub level "Vertex" (subobjectLevel = 1)
  • Selects all vertices on that level (actionMan.executeAction 0 "40021")
  • Weld all the selected verts by a threshold value (splineOps.weld $)

Thanks in advance

0 Comments
2021/11/08
12:34 UTC

1

Create camera from EXIF

0 Comments
2021/10/27
09:08 UTC

2

ID Finder script

With this script you can Find what kind of object and material IDs you have in your scene.

Download ID Finder

You can give random IDs and you can delete some of them .

Wish you a nice day 😊

0 Comments
2021/07/17
17:24 UTC

1

Script to select all 'similar objects' in scene, then attach them together

20 yrs using max no idea how to use max script. Any kind stranger's want to help me out? Would be much appreciated.

1 Comment
2021/06/15
16:05 UTC

1

Batch Render Preset

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?

0 Comments
2021/05/04
04:13 UTC

Back To Top